[ruby-talk:02519] Re: frozen behavior

From: matz@... (Yukihiro Matsumoto)
Date: 2000-04-20 05:44:49 UTC
List: ruby-talk #2519
Hi,

In message "[ruby-talk:02514] frozen behavior"
    on 00/04/19, Andrew Hunt <Andy@Toolshed.Com> writes:

|I've got a quick question regarding the behavior of "frozen".
|Are you supposed to be able to add methods to a frozen object?

|Is this correct behavior?

It's intended behavior.  I consider defining singleton method to
frozen object should be prohibited, because I think it is kind of
modification.

|And what is magic about these fourstrings that they are frozen?

Hmm, 

|  Trying to modify String "\n": can't modify frozen object

is $/(rb_default_rs), which is frozen in io.c.

|  Trying to modify String "Struct": can't modify frozen object
|  Trying to modify String "File": can't modify frozen object
|  Trying to modify String "Errno": can't modify frozen object

I have no idea why they are frozen.  I'll check on them.

							matz.

In This Thread