From: Bill Kelly Date: 2004-06-26T01:16:30+09:00 Subject: Re: Is it considered Harmful? From: "Sean O'Dell" > On Friday 25 June 2004 02:19, ts wrote: > > >>>>> "S" == Sean O'Dell writes: > > > > S> variables it might not expect (buyer beware), it seems like we ought to > > be S> able to do that. I don't believe there's any solid technical block > > to doing S> this, is there? > > > > If you think that the possiblity to crash ruby is not a technical reason, > > then you are right it don't exist solid technical reason. > > You're wrong on that. It wouldn't crash Ruby to change the class of an > object. Objects already change their class when you turn them into > singletons. Changing it to any class of your choosing would be even simpler, > since creating a singleton involves inheriting all the old class methods; > changing a class wouldn't require all that work. Supposed an object's class were changed to a different class which was itself (or whose ancestor(s) were) implemented in 'C' code. Something that expects that once it's initialized it can go ahead and rely on its class invariants pointing to real operating system file handles, window handles, etc. Like, hypothetically, "hello".class = OpenGLCanvas "hello".class = IO ...or whatever. For example: x = "hello" x.class = OpenGLCanvas x.PushMatrix() kind of thing. Should we expect a hard crash here? If so, is that OK because it's "programmer error" and not really Ruby's fault? I haven't done enough Smalltalk to know what #become would do in such situations... Regards, Bill