First Draft: Static Single Assignment

Peter C peterc at gmail.com
Mon Nov 17 06:18:27 UTC 2025


On Monday, 17 November 2025 at 01:08:58 UTC, Walter Bright wrote:
> On 11/16/2025 2:08 PM, Nick Treleaven wrote:
>> On Sunday, 16 November 2025 at 01:50:16 UTC, Walter Bright 
>> wrote:
>>> https://github.com/WalterBright/documents/blob/master/final.md
>> 
>> ```d
>> final int f = 3;
>> f = 4; // error, f is final
>> int* p = &f; // error, cannot make mutable reference to final 
>> variable
>> const int* pc = &f; // ok
>> ```
>> 
>> So I assume `typeof(&f)` would be `const int*`?
>
> `final` is not part of the type system. So typeof(&f) would be 
> `int*`.
>
>
>> ```d
>> int i;
>> final int* pi = &i;
>> auto p = pi;
>> ```
>> Is `p` final or const?
>
> ```d
> int* p = pi;
> ```

The auto keyword should properly deduce the full declaration of 
the initializer (pi), not just its type.

If auto *only* copied the type (int*), the resulting variable p 
would be a simple, mutable pointer (int* p). This would allow the 
user to immediately reassign it.

The semantics of 'final int* pi = &i;' needs to be fully retained 
by the auto keyword, otherwise the safety and guarantees provided 
by the original declaration are lost in the new variable.

In summary, it is *the duty* of auto to also copy the binding 
restriction!



More information about the dip.development mailing list