News for hackers. Stuff that matters.
Re:John Carmack on Mutable Variables by bathtub365 on Friday October 31, 2025 @01:25AM (#45768692)
Are there languages that automatically extend this to things like data structure members? One of the things I like about the C++ const keyword is that if you declare an instance of a struct/class as const it extends that to its members. If the instance isn’t const, you can still mutate them (as long as they aren’t declared const within the structure itself)
Re:John Carmack on Mutable Variables by orlp on Friday October 31, 2025 @04:21AM (#45769515)
Rust works this way, yes. There are escape hatches though, which allow interior mutability.
Re:John Carmack on Mutable Variables by snalty on Friday October 31, 2025 @04:25AM (#45769554)
Re:John Carmack on Mutable Variables by umanwizard on Friday October 31, 2025 @04:23AM (#45769534)
If I understand what you’re asking correctly, rust is also like this. If you have a non-mut value of (or non-mut reference to) an object, you only get non-mut access to its members.