From: Sean O'Dell Date: 2004-06-26T01:49:11+09:00 Subject: Re: Is it considered Harmful? On Friday 25 June 2004 09:16, Bill Kelly wrote: > 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. No code should "expect" data to be there that isn't. If a C extension wraps a native C struct as a Ruby object with Make_Struct, then when it unwraps it, and gets nothing or a NULL pointer, it shouldn't continue to try and use it. That's sloppy coding. Sean O'Dell