Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Freeze functions for package-level collections #41904
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.