google / google/xls

[DSLX] Path-update operator `:=` (mutation-free)

Open
#82 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.