First Draft: Static Single Assignment

Peter C peterc at gmail.com
Mon Nov 17 06:03:08 UTC 2025


On Sunday, 16 November 2025 at 22:08:02 UTC, Nick Treleaven wrote:
> ..
> int i;
> final int* pi = &i;
> auto p = pi;
>
> Is `p` final or const?

int i;
  - A simple integer variable i is declared. Its value is mutable 
(can be changed).

final int* pi = &i;
  - pi is a single-assignment pointer binding - the address stored 
in pi cannot be reassigned to a different address. So pi is 
conceptually immutable, but not technically in the same way a 
const pointer is, since const is a type qualifier, and -> binding 
restriction != a type qualifier. The result is the same, in that 
there is a binding lock, but one is *not* done by the type system 
(final), and one *is* done by the type system (const).

"technically immutable" is still reserved for things defined by 
*type* qualifiers like const or immutable.

(note: the integer value at that address is still mutable!)

auto p = pi;
  - Since final (or init) is a binding restriction and not a type 
qualifier, then the deduced variable p must be final. That is, 
auto copies the binding restriction (final) and the base type 
(int*). The resulting variable, must be: final int∗



More information about the dip.development mailing list