First Draft: Static Single Assignment
Peter C
peterc at gmail.com
Mon Nov 17 21:57:39 UTC 2025
On Monday, 17 November 2025 at 15:05:17 UTC, jmh530 wrote:
>
> Would it make sense to make final/head-const part of the type
> system? Other than that it makes it more difficult to implement.
>
> I recall there were a lot of discussions in the past about
> converting something that is head const to tail const, or maybe
> the reverse. I think the issue was that it was built-in for D's
> arrays, but you can't easily do that if you have your own
> aggregate. There seemed to have been some desire to have that
> functionality in the language.
Wouldn't this change the re-engineering scope of final from
low-impact (a local compiler rule check - essentially a hack) to
high-impact (a fundamental redesign of the type system).
It seems improbable [to me at least], that Walter would seriously
consider fundamentally redesigning the type system.
The most pragmatic option here, is the Minimal Viable Change
(MVC) approach - i.e one that satisfies the guarantee of SSA
immutability without incurring massive technical debt.
- Goal: Guarantee SSA immutability.
- Method: Use a simple declaration constraint (metadata) on the
variable identifier.
- Safety Net: Use the existing, well-understood mechanism of
synthesizing a const pointer when the address is taken, which is
the necessary "hack" to uphold the original final promise.
More information about the dip.development
mailing list