Dave Thomas <Dave / pragmaticprogrammer.com> wrote:

> Same goes for Bignums (they also are not mutable). I'm not sure what
> you're getting at.

Hi Dave,

I guess probably it is true that for now we have to put the implementation
issue aside.  Well, then probably the question is, given the Ruby built-in
classes, officially which are mutable and which are immutable and
why?  This is because one of the posters stated that to him it seems that
the mutability designation is arbitrary (i.e., some work for chars
(strings of length one) but not for Fixnums).

I don't think the concept of mutability is ever mentioned in the pickaxe
book.  In "Python Essential Reference", for example, the concept of
mutability is introduced early, and it seems that in Python (at least in
version 1.5.2) only lists (arrays) and dictionaries (hashes) are mutable.

When I used Python, the fact that a string is immutable annoyed me.  But
like you said, it can be very useful to prevent bugs.  Right now, I think
the problem is not whether Fixnums and strings (and others) should be
mutable or immutable (so far it seems there is no concensus, at least for
strings), but the plain fact, that in Ruby, it seems the concept of
immutability is never treated in a formal way.  I think this is why this
thread has become so long; each person has his own idea why Fixnums are
immutable while strings are mutable.  I think it will suffice for all of
us if Matz simply gives the formal list of which objects/classes are
mutable and immutable.  I agree with you that the implementation is
secondary.

Regards,

Bill