First Draft: Static Single Assignment
Peter C
peterc at gmail.com
Fri Dec 5 23:25:41 UTC 2025
On Friday, 5 December 2025 at 23:05:54 UTC, Juraj wrote:
> On Friday, 5 December 2025 at 22:35:04 UTC, Peter C wrote:
>> On Tuesday, 2 December 2025 at 07:50:57 UTC, Walter Bright
>
>> This should be allowed:
>>
>> final int x; // A final variable declared without an
>> initializer.
>> x = 42; // currently getting -> Error: cannot modify `final x`
>
> I suggest keeping the topic about D and not a hypothetical
> language.
> I in this case `x` is already initialized, so by this DIP, it
> can not be changed.
also, if final is ever going to work with class fields, then if
default initialization is considered an assignment, then you
won't be able to write code like this:
class Config
{
final int port; // declared, default initialized to 0
this(int p)
{
port = p; // explicit assignment - allowed once.
}
}
More information about the dip.development
mailing list