I haven't used const much in the past because I got burned on transitive const, so I managed to confuse myself. I am not really interested in const/immutabel references here, but values. Seems like there is no reason to ever use const values, except when they contain a pointer to something non-immutable?

The only difference, as far as I can tell, is if the value type has pointers to other objects, immutable requires them to be to immutable objects. Which is a bit odd when you think of it. It basically means that you cannot put pointers to memory registers in ROM in a type safe manner... :-/ . That is a very odd restriction, because that is something you might want to do...

Seems to me that immutable should allow pointers to mutable memory and that const really shouldn't have been applicable to values, but only to pointers.

Anyway seems the rule of thumb is to:

- always use immutable on values
- except when the value might contain a pointer to non-immutable

Hm.

Reply via email to