First Draft: Static Single Assignment
jmh530
john.michael.hall at gmail.com
Mon Nov 17 15:05:17 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*`.
Would it make sense to make final/head-const part of the type
system? Other than that it makes it more difficult to implement.
I recall there were a lot of discussions in the past about
converting something that is head const to tail const, or maybe
the reverse. I think the issue was that it was built-in for D's
arrays, but you can't easily do that if you have your own
aggregate. There seemed to have been some desire to have that
functionality in the language.
More information about the dip.development
mailing list