From: "David A. Black" Date: 2005-04-22T09:44:39+09:00 Subject: Re: [EVALUATION] - E03e - The Ruby Object Model (Summary) Hi -- On Fri, 22 Apr 2005, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [EVALUATION] - E03e - The Ruby Object Model (Summary)" > on Fri, 22 Apr 2005 09:32:08 +0900, "David A. Black" writes: > > |> I'm not sure why singleton modules are better than singleton classes. > | > |I didn't express that thought very clearly. I was thinking: modules > |are already a sort of "class-like" (but non-instantiable) object. But > |it's probably not relevant, since I think what you're talking about is > |implementations that avoid the whole container-creation process. > > Yep, singleton class is a long lived object under the current > implementation. The temporal class-like object can reduce number of > live objects. Note that I'm not yet sure if it's a good idea or not. > I just don't want to deny the idea before knowing it's bad. Maybe the best thing (easy for me to talk about since I don't have to implement it :-) would be a kind of "class interface" to the object's singleton methods. If you did: def obj.new_method end no Class would be created. But if you wanted to do other things, you could still do: class << obj include SomeModule @var = 1 end etc. "self" in that scope could be a different thing each time (sort of like Object#method). David -- David A. Black dblack@wobblini.net