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

Closed
mcandre opened this issue Oct 10, 2020 · 2 comments
Closed

Freeze functions for package-level collections #41904

mcandre opened this issue Oct 10, 2020 · 2 comments

Comments

@mcandre
Copy link

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.

@go101
Copy link

go101 commented Oct 10, 2020

Do you mean #6386?

@mvdan
Copy link
Member

mvdan commented Oct 10, 2020

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

@mvdan mvdan closed this as completed Oct 10, 2020
@golang golang locked and limited conversation to collaborators Oct 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants