[ruby-talk:02527] Re: frozen behavior

From: Dave Thomas <Dave@...>
Date: 2000-04-20 08:53:25 UTC
List: ruby-talk #2527
matz@netlab.co.jp (Yukihiro Matsumoto) writes:

> |1. There's no change to the _state_ of an object if you add a method
> |   to it, so you're not violating the freeze.
> 
> I feel set of individual (singleton) methods of an object is included
> in the state of the object.

Surely it's in the object's class, not the object itself.

> |2. Why allow

> |       a.freeze
> |
> |       class String
> |  but not
> |       def a.xxx
> |       end
> 
> Hmm, I kinda feel like changing String class is altering the global
> status.  But the result is almost same as you mentioned.

Even worse - if someone wants to add a method to a particular object,
and the object is frozen, then they might be tempted to make the more
global change to the object's class instead. This would be
bad--changing all objects because you were frustrated while trying to
change one.

How am I doing?


Dave


ps. Any thoughts on the change in parsing of function calls that seems 
to have happened in the latest checkout?

In This Thread