Index and Field Assignment via Copy-on-Write Desugaring

5 sections

0%
Overview

Implement index and field assignment syntax (list[i] = x, state.name = x, mixed chains state.items[i] = x / list[i].name = x, nested grid[x][y][z] = v, compound list[i] += 1) as type-directed copy-on-write desugaring. list[i] = x desugars to list = list.updated(key: i, value: x) via the IndexSet trait; state.f = x desugars to state = { ...state, f: x } via struct spread. Under ARC at refcount==1 (the common local-binding case) the copy is optimized to in-place mutation. Root binding must be mutable (non-$, not a parameter, not a loop variable).

In Progress

1 sections

Planned

4 sections