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

Re: the benefits of immutability

Vadim Nasardinov <el-vadimo@comcast.net> writes:
> On 09 Aug 2003 14:20:45 -0400 (Message-ID:
> <87bruyofpe.fsf@snark.piermont.com>), Perry E. Metzger wrote:
>  > I recently wrote a (partial) Scheme interpreter in Java to learn
>  > Java better, but part of what I learned what how limiting Java
>  > is. Not having function pointers sucks big time, as does not being
>  > able to subclass a class like String
> The finality of the String class is a consequence of its immutability.

That's just plain incorrect. Obvious evidence is that there is also a
mutable string type and it is also final -- i.e. cannot be
subclassed. Just because the strings themselves are immutable doesn't
mean that you can't safely add extra methods etc. to a subclass. The
two are unconnected.

> With the availability of StringBuffer as a mutable companion of
> String, I honestly can't remember when was the last time I wished
> String were not final.

StringBuffer is also final. You can't subclass it, either.

I think you miss the point.