From: Mathieu Bouchard Date: 2005-04-24T11:22:34+09:00 Subject: Re: [ANN] Article: Seeing Metaclasses Clearly ---1077017559-1369306703-1114308715=:17107 Content-Type: MULTIPART/MIXED; BOUNDARY="-1077017559-1369306703-1114308715=:17107" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1077017559-1369306703-1114308715=:17107 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: 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 :) The instance-of relationship is not about creatability of new objects: it= =20 is about which object represents the behaviour of which other object,=20 period. In the case of singleton classes, the instance is created *before*= =20 the class is, and it doesn't follow that this peculiar creation order=20 makes that relationship a lesser-instance-of or a non-instance-of. Where the "singleton" name really breaks is with indirect instance-of=20 relationships: for example, (Object) has many indirect instance-of=20 relationships, with *all* Ruby classes in the system, and you can=20 instantiate the (Object) class as many times as you want to, and you=20 always do whenever you are subclassing any class whatsoever, because every= =20 instance of Class is also an instance of (Object). (note: the general instance-of such as Module#=3D=3D=3D is transitive in th= e=20 sense that it also includes instance-of-subclass-of and so on: every=20 object is an instance-of Object.) > 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). I have trouble following that... we seem to both agree and disagree on=20 the same thing at once...! Maybe it's because of confusing the Object#class method with which is the= =20 direct-instance-of relationship of an object. The latter cannot be=20 observed in Ruby: if an object x has no S-class, then it's=20 directly-instance-of the result of x.class, and if an object has a=20 S-class, it's directly-instance-of the result of (class<