From: "David A. Black" Date: 2005-04-20T20:13:41+09:00 Subject: Re: [ANN] Article: Seeing Metaclasses Clearly Hi -- On Wed, 20 Apr 2005, Jim Weirich wrote: > It also makes the name "Singleton" class a little odd. I thought it was > because a singleton class could only have a single instance. Now I find out > it can't even have that. Perhaps they should be Zeroton classes :) I always thought it was singleton in the sense that, unlike the "birth class", it was not shared with other objects. There is of course a long history of discussion about the term "singleton", and the fact that it's overloaded.... I've suggested "own class", and others have suggested other terms, though I don't know that even a pronouncement from Matz will change usage completely. >>> Indeed, Class is the Metaclass from which all the singleton metaclasses >>> derive. >> >> And all other Class objects too. > > Only things (that would be called metaclasses if they could only have > instances) are derived (i.e. inherit) from Class. All other class objects > are merely instances of Class. But being a (mere) instance of Class is, I think, by far the closest thing in Ruby to matching the proto-cookie-cutter thing. (I know that's just an analogy, but Class actually fits it rather well.) Not that every instance of Class is a metaclass, but rather that Class is a metaclass, on account of the fact that it can create new classes (meta or otherwise). >> But then "[Mm]etaclass" becomes >> really kind of overloaded -- in the sense that on the one hand it is a >> suitable term for Class (which is truly the thing that stamps out the >> cookie cutters themselves), while on the other hand it gets used as a >> term for something which is unequivocally *not* in the cookie-cutter, >> meta-cookie-cutter, or factory family at all. > > The formal definition does not require metaclasses (or classes) to create > instances ... only that they /have/ instances (which is you so clearly > demonstrated singleton classes have no instances). The factory aspect was > entirely part of the analogy and not part of the formal definition. Like "singleton", though, this may be a case where Matz isn't using it in a way that fits precisely with any previous formal definitions. I guess that's one of the hazards of writing a language with a cool, uncommon design :-) David -- David A. Black dblack@wobblini.net