From: dblack@... Date: 2005-12-10T13:20:37+09:00 Subject: Re: About class methods On Sat, 10 Dec 2005, Trans wrote: > > jonathan leonard wrote: >> T, >> >>> Any given >>> class can have infinitely many singleton subclases, no? >> >> Oops. This statement from the page you linked to seems to answer that >> question: >> >> If 'a' already has a singleton class then any more singleton methods you >> define are just added to it. >> >> Does this mean that a class can have only one singleton subclass and >> that all methods added anywhere in the program are added to that single >> instance? If so, I wonder why this is. It seems to me to be more >> useful if you can have infinitely many singleton subclasses. I suppose >> you still can have divergence of this sort with individual instances, >> but why not with the class itself? > > Well, I think its basically because Matz used the class nothing more > then an easy way to implement ad hoc methods. It was the methods that > mattered to him, not the class --the class was just a vehicle. He's > talked about the possibility of not utilizing the class in the future. > I assume that means these methods would then just exit in a separate > underlying namespace of the class, as opposed to a separate class > altogether. Which may also be the reason he's allowed then name to > remain a bit amorphis and never provided a convenience method for > accessing it. The latter, yes, from what Matz has said (no convenience method because it may not be a class in the future). The former -- amorphous name -- no: I am using the term "singleton class", and I will use it until we find the better term as I said in [ruby-talk:141548] 7 months ago in the famous Ilias thread. That sounds pretty non-amorphous :-) But the whole thing may indeed become non-class-based. I'm not sure what that would entail. I kind of think that if it were something other than a class, one would end up longing for a "class interface" to it, and then it might as well be a class.... David -- David A. Black dblack@wobblini.net "Ruby for Rails", forthcoming from Manning Publications, April 2006!