First Draft: Static Single Assignment
Juraj
junk at vec4.xyz
Sat Dec 6 00:34:01 UTC 2025
On Sunday, 16 November 2025 at 01:50:32 UTC, Walter Bright wrote:
> Oops!
> https://github.com/WalterBright/documents/blob/master/final.md
In the DIP:
> final can be applied to struct and class fields.
But in this thread
(<https://forum.dlang.org/post/10gou85$2p0e$1@digitalmars.com>) :
> `final` for fields is not currently implemented with the PR. I
> have suspicion that it is > unreasonable to implement it. The
> problem is that fields can overlap each other in messy > ways
> (i.e. unions of structs). Trying to tease out finality in that
> soup may be not worth > the bother.
IMO, this should be put into the DIP (at least as a note),
otherwise people may get the wrong idea about what this feature
enables.
For me personally, this whole thing does not looks like its worth
the bother.
The examples in the DIP and in the PR tests show nothing I would
not use `const` if I was getting my code in a state where I fear
re-assign.
The motivation behind this is more readable code, but adds ton of
cognitive load:
As I understand it, final will match on non-`cost` parameters,
but instead `ref`, it will match `const ref`.
That will be confusing.
But my main worry is, that the DIP process will be sidestepped,
as this feature can be presented as a pure addition that does not
break old code. I hope this will not be the case.
More information about the dip.development
mailing list