I've recently asked if it's time to revisit the decision to make structs in maps in Go mutable, and was politely declined, with a reference to this being a refusted proposal since 2012:<p>https://github.com/golang/go/issues/53857<p>Since arrays work fine, if a is a slice or an array:<p>a[10].field = 42<p>it seems bogus that maps don't; this doesn't compile in Go if m is a map:<p>m[10].field = 42<p>In both cases, the address of the struct is calculated at runtime, as it must be known to access the field.<p>Instead of leaving this as a rant, let's make it a question: what's your "what is this insanity?" peeve with your favourite language?
> it seems bogus that maps don't; this doesn't compile in Go if m is a map:<p>It does not seem bogus to me. Values in a map are not addressable for a good reasons. It allows more freedom in implementing a map. Arrays, on the other hand, are specified to be continuous in memory, hence the implementation is set in stone.<p>Also, non-existent items of a map return the zero value as specified. Now assume the map items are addressable. What exactly should happen if you refer to a field of a map item that is not in the map? Is there a possibility that is not surprising?