First Draft: Static Single Assignment

Peter C peterc at gmail.com
Wed Dec 3 22:07:03 UTC 2025


On Wednesday, 3 December 2025 at 10:53:04 UTC, Dom Disc wrote:
>
> This doesn't seem to be very useful. If you want a dynamic 
> array that can't change length, why don't you use a static 
> array?!?

No, I wanted an array that *can* change length (i.e. a dynamic 
array), but where the variable holding the reference to that 
array cannot be reassigned.

The actual problem is, a mismatch between my mental model (~= is 
mutation) and the implementation model. Conceptually, ~= is a 
mutation, but technically it's reassignment, because 
under-the-hood, when ~= is used, the variable's slice header is 
updated with a new reference (pointer + length), which the 
compiler treats as reassignment. So technically, what I want 
cannot be allowed.

In essence, you can't have a 'final' dynamic array that still 
grows and shrinks.

Instead, I'd need to implement some form of indirection 
(struct/class wrapper) to separate "mutation of the contents" 
from "rebinding of the slice header."

Oh well.

I expect there are many more mismatches (mental model vs 
implementation model), to be uncovered, because 'final' is not 
the most intuitive abstraction.


More information about the dip.development mailing list