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

diverge() like a clone()? #4

Open
getify opened this issue Oct 12, 2019 · 2 comments
Open

diverge() like a clone()? #4

getify opened this issue Oct 12, 2019 · 2 comments

Comments

@getify
Copy link

getify commented Oct 12, 2019

Is diverge() like a clone()? Why not call it clone?

And is the diverging/cloning shallow or deep?

@erights
Copy link
Collaborator

erights commented Oct 13, 2019

Staying with the Map example for concreteness.

I would expect x.clone() to produce something of the same type as x. x.diverge() is not like x.clone(), in that x.diverge() always results in a new mutable Map, even when x is a ReadOnlyMap or a FixedMap.

It is shallow, because it is only about the collection, not the values contained in the collection.

@getify
Copy link
Author

getify commented Oct 13, 2019

Is it an expected use-case that you'll want to go from a read-only or fixed map back to a mutable map so you could make a mutation and then roundtrip right back to the read-only/fixed version?

I'm trying to conceptualize the usage of these data structures vs the "immutable data structures" proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants