[squeak-dev] decomposing immutibility
bert at freudenbergs.de
Thu Mar 18 17:58:51 UTC 2010
On 18.03.2010, at 18:41, Ralph Boland wrote:
> Allow me to make the following definitions:
> 1) Objects with no instance variable are immutable. (Is that a good
> 2) If an object's instances variables cannot be assigned to then the
> object is locked.
> 3) An object is immutable if it has no instance varibles (i.e. 1)) or
> if has instance variables
> and they are all immutable.
... and it must be locked, in your definition. Otherwise you could store stuff into it so it's not immutable.
Also, it's not just instance variables, but indexable fields too.
Anyway, I can see no real value in this "decomposition". "Locking" is necessary for immutability, sure. But I'm not sure how useful "locking" would be if the "locked" inst vars had mutable values. I think the "lock/beImmutable" primitive should fail if any slot contained something mutable.
- Bert -
More information about the Squeak-dev