Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support element assignment with persistent data structure #422

xiaq opened this issue Jul 9, 2017 · 0 comments

Support element assignment with persistent data structure #422

xiaq opened this issue Jul 9, 2017 · 0 comments


Copy link

@xiaq xiaq commented Jul 9, 2017

After #414 gets implemented, maps will be persistent and thus immutable. This means that individual elements in maps can no longer be assigned, at least under the current semantics:

m = [&foo=bar &lorem=ipsum]
m[foo] = quux # will no longer work

Elvish's persistent data structures are based on data structures in Clojure. Clojure does not support element assignments either; instead, there is an assoc function that returns an altered version of the original structure; see #414 for how an Elvish assoc will look like.

However, it is possible to implement element assignments as a syntactical sugar:

m = [&foo=bar &lorem=ipsum]
m[foo] = quux # equivalent to the following line
m = (assoc $m foo quux)
@xiaq xiaq added the bug label Jul 9, 2017
@xiaq xiaq modified the milestones: 1.0, 0.10 Jul 9, 2017
xiaq added a commit that referenced this issue Aug 31, 2017
@xiaq xiaq closed this Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.