Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure I fully understand what you're proposing? Is it about function purity or immutable values?

I think the way to do the latter in Go is to not export the field and only have it modifiable by a dedicated method. (or even enforce copy-on-write).

And passing values instead of pointers where needed.

I don't think that breaking compatibility to add a mut keyword would fit Go. It makes more sense for rust.

(especially wrt interior mutability... That would make it a very pervasive change, probably too much of a change)

Another thing is that wrapping values in an empty interface essentially make those immutable. It doesn't necessarily have mechanical sympathy but as long as you don't wrap pointers, it would be difficult to modify (no aliasing).

Then again, it's more defensive and pragmatic coding than something that proves functional purity. Seems that it is enough.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: