First Draft: Static Single Assignment

Peter C peterc at gmail.com
Mon Nov 17 11:34:22 UTC 2025


On Monday, 17 November 2025 at 09:58:22 UTC, Nick Treleaven wrote:
>..
> I think it needs to be `const(int)*` to protect `f` from ever 
> being mutated. If `&f` is part of a complex expression (e.g. 
> `(*[&f][0])++`) I think practically we can only enforce that 
> using `const`.

Again, I have to correct my thinking, and agree with you here.

To enforce the guarantee of 'final', typeof(&f) must result in a 
pointer type that prevents data write access to f.

Any other type (like a simple int*) would allow write access, 
thereby invalidating the guarantee provided by final.

..................
final int f = 3;
int* p = &f; // Error
const int* pc = &f; // ok
typeof(&f); // const(int)*
................





More information about the dip.development mailing list