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

Freeze functions for package-level collections #41904

mcandre opened this issue Oct 10, 2020 · 2 comments

Freeze functions for package-level collections #41904

mcandre opened this issue Oct 10, 2020 · 2 comments


Copy link

@mcandre mcandre commented Oct 10, 2020

Please provide standard functions for generating immutable collections, including slices and hashmaps, safe for use as package-level members.

I think it is too late to require pointers in order to modify collections, at least within Go 1.x. We may have to superimpose a freeze() function returning an immutable, potentially type-distinct, flavor of collections.

Rust has this. Ruby has this. Haskell has this. Clojure has this. Python has third party libraries for this.

C/C++ probably require wrapper functions, meaning that developers can easily expose mutable collections without intending to.

Copy link

@go101 go101 commented Oct 10, 2020

Do you mean #6386?

Copy link

@mvdan mvdan commented Oct 10, 2020

Duplicate, and also closing as per #41739 (comment).

@mvdan mvdan closed this Oct 10, 2020
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
3 participants
You can’t perform that action at this time.