You mean that you could create a struct with a field that is
immutable, right? I assume that the way you'd create such immutable
objects is via the constructor only. Also, you'd just not have any
setters for that field, right?
I'm not sure this would get you all the way to the hashability you're
looking for. Maybe it's just the terminology I'm thinking in is
different, but what you want is a run-time flag to set immutability,
not a compile-time immutable field. You'd do something like
myObj.setImmutable(), and it would make all the setters throw
exceptions, as well as have the sense to trickle down to all the
mutable subordinate objects. This approach wouldn't work in all
generators (default Java, for instance, since there ARE no setters,
just fields), but should work for most.
-Bryan
On Oct 19, 2008, at 5:57 AM, Esteve Fernandez wrote:
Hi all, what do you think about adding an "immutable" type
modifier? Having
immutable objects would make them hashable, thread-safe, etc. well,
you
already know the advantages.
Cheers.