"Sean O'Dell" <sean / celsoft.com> writes: > On Monday 28 June 2004 05:45, Patrick May wrote: > > Sean, > > > > On Monday, June 28, 2004, at 01:07 AM, Sean O'Dell wrote: > > >> If an object of SomeClass becomes a Tempfile (or any other class with > > >> significant internal state), which class is responsible for the > > >> initialization work? > > > > > > The class that created the object should have already initialized it. > > > Initialization is part of object creation, usually. > > > > So, SomeClass is responsible for initializing an object not only for > > its own purposes, but also for Tempfile's purposes? > > > > How does SomeClass know that you'll want to change the object's class > > to a Tempfile, and not a Net::HTTP? > > > > Do you see how this absurdity is the logical outcome of your statement? > > I think you're not understanding what class= does. > > All class= does is change an existing object's class. The object already > exists; it was already initialized and is ready for use. All class= does is > simply change the object's class. All the initialized data is still there > with the class; still initialized. The object doesn't have to be initialized > in any particular way. The original class doesn't have to do any extra work > at all; none. All that happens is, the existing object's class is changed. > A class is pretty much just a container of methods, so all you're really > doing is changing all of the object's instance methods. But the initialize > method doesn't matter because the object already exists and doesn't need to > be called again. > > Sean O'Dell I think what Patrick means is that all methods assume that their class's initialization method has been called. Currently, it's guaranteed to be called, since #new calls it. What you're proposing -- #class= -- removes that guarantee. mikael