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

That's a misnomer, not a misgiving.

val/var/const/whatever only describe the reference, not the value. It doesn't really make sense for that annotation to, say, swivel a collection between ImmutableList and MutableList.

Now, you might be right that it's confusing, this difference between reference mutability and value mutability. I see beginners struggle with it in Javascript's new let vs const all the time.



Even with Object.freeze() it only prevents mutation of the top-level keys.




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

Search: