First Draft: ref For Variable Declarations
Nick Treleaven
nick at geany.org
Fri Apr 19 07:23:22 UTC 2024
On Wednesday, 17 April 2024 at 14:29:17 UTC, Dukc wrote:
> On Wednesday, 17 April 2024 at 14:07:04 UTC, Richard (Rikki)
> Andrew Cattermole wrote:
>>
>> Currently the DIP only shows aliasing of variables,
>> expressions like the above do not appear to be supported.
>
> If that was the case this DIP would be completely useless, as
> you could already do everything it enabled with `alias`.
>
> I'm sure the intended restriction is the same as with `ref`
> function parameters: the expression must be an lvalue.
The behaviour could perhaps be defined as follows - if this would
compile:
```d
(ref p) { CODE }(lvalue);
```
Then, with some restrictions on `CODE`, you can write:
```d
ref p = lvalue;
CODE
```
And the effects will be equivalent. `CODE` cannot contain
`return` statements or `__traits(parameters)`,
`__traits(parent)`, `is(T PS == __parameters)` expressions. Have
I missed anything else?
More information about the dip.development
mailing list