From: Sean O'Dell Date: 2004-06-26T04:21:41+09:00 Subject: Re: Is it considered Harmful? On Friday 25 June 2004 12:13, Charles Comstock wrote: > Sean O'Dell wrote: > > On Friday 25 June 2004 09:15, ts wrote: > >>>>>>>"S" == Sean O'Dell writes: > >> > >>S> It should be very easy to do. I'm wondering if a C extension could > >>possibly S> even do this. > >> > >> You are right, a C extension can effectively crash ruby > >> > >> Read carefully hash.c and array.c and just imagine what will be the > >> result if one method of hash.c will be applied to an array. > >> > >> matz has one day say it in a message to ruby-talk : one information is > >> missing > > > > You can do all sorts of things with Ruby, I see no reason why changing an > > object's class would crash Ruby anymore than, say, redefining a method to > > something different than an object expects, or including modules in a > > class that don't belong there. Just be careful of what you're doing. I > > see no FUNDAMENTAL reason why you couldn't change an object's class. > > > > Sean O'Dell > > All of those places that you can assume the underlying datatype hasn't > changed result in increased performance for us because there is no need > to double check the type. If you have #class= then you would have added > overhead on a significant portion of the code for a small use case. > While this isn't a fundemental reason it is a logical reason why it may > have been avoided in the first place. Why don't you try and make a > patch that allows this on your own copy and compare performance and the > like? Actually, the comparison is a function call that mostly just checks a bit mask. That's overhead, but fairly minimal I think. Sean O'Dell