Hacker News new | ask | show | jobs
by parasense 1425 days ago
I'd really love to see container constants. As of this writing only strings or numbers can be set constant.

``` const map[uint8]string { 0: "thing1", 1: "thing2", } ``` That way tables of data can be made immutable at compile.

Folks are left to invent stupid hacks, that don't really work. For example, a function that defines a template and returns:

``` func my_data() map[uint8]string { return map[uint8]string { 0: "thing1", 1: "thing2", } } ```

And then we have folks running silly function calls for the sake of avoiding mutability.

Don't get me wrong, I understand why this hasn't been done. We've all read the arguments against adding things to the language, but I accept in part, and reject in part that argument. Complexity always increases, so it's understandable to put the brake on run-away complexity. But GO is slightly pathological when it comes to the avoidance of adding sensible language features. The thing is most folks would rather have a slightly more complex compiler than a limiting programing language.