-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposalv2An incompatible library changeAn incompatible library change
Milestone
Description
I'm not sure why there is no way to create a slice's from another, with a capacity lower than it's length.
It has a few uses. For example, I could pass in a copy of my slice set to 0 capacity to benefit from copy-on-write semantics. The length would still appear to have N items, but trying to write to any of them would trigger the slice to re-grow. This would allow for immutable, lightweight slices in general.
I'm not certain if it would break any code, I've seen almost noone calling "cap" in my experience.
cznic, OneOfOne, davecheney, AlekSi, tmthrgd and 2 moretmthrgd
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposalv2An incompatible library changeAn incompatible library change