[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: the benefits of immutability



On Sunday, August 31, 2003, at 07:19 AM, Damien Diederen wrote:
> Now we can see why StringBuffer is final: it *must* ensure that the
> buffer it shares with the string object will not be modified anymore, 
> or
> the "strings are immutable" constraint would be violated. The safest 
> way
> to ensure that is to seal the class.

Could a `seal' method be put into Object that would make an instance 
immutable?  You'd need an isImmutable method too.  There has to be a 
way of letting StringBuffer users have their cake and eat it too.

Geoffrey
--
Geoffrey S. Knauth | http://knauth.org/gsk