[DSLX] Path-update operator `:=` (mutation-free)
Open
dslx
long-term-enhancement
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
It's convenient to have a shorthand notation for "deeper path" updates, say to a struct that carries nuanced data from "tick" to "tick" (which ultimately is state since it iterates in time, even though we don't mutate it). I was thinking of this shorthand syntax -- it'd be convenient to do something like:
`s.data[foo][bar] := u32:42;`
which would basically do:
`let s = State{data: update(s.data, foo, update(s.data[foo], bar, u32:42)), ..s};`
as a desugaring so you don't need to write it all out. Note that this operator is rebinding the "outermost" referenced identifier (in the scope in which it's written).
Contributor guide
Assessment
This issue has not been assessed yet.