First Draft: Static Single Assignment
Nick Treleaven
nick at geany.org
Wed Dec 3 10:18:50 UTC 2025
On Wednesday, 3 December 2025 at 04:05:28 UTC, Peter C wrote:
> class Bag
> {
> final int[] items; // This is a binding-level guarantee -
> also acts an API invariant.
> this() { items = []; }
> }
>
> void main()
> {
> auto b = new Bag();
> b.items ~= 1; // fine. still mutable.
> b.items = []; // was expecting an error here??
> }
Just to note that final on a dynamic array `a` should mean that
`a.ptr` and `a.length` never change, but elements e.g. `a[0]` can
change. So if final was allowed on fields, both assignments above
would error.
More information about the dip.development
mailing list