From: "David A. Black" Date: 2005-10-03T21:26:17+09:00 Subject: Re: Cannot subclass Class? Hi -- On Mon, 3 Oct 2005, Hal Fulton wrote: > David A. Black wrote: >> >> Singleton classes in general are definitely not deep magic. They're >> just the way Ruby handles requests for per-object method definitions: >> stick them in a per-object class. They're not particularly meta; >> they're just anonymous classes. > > It has always bothered me a tiny bit to call them classes at all; > after all, you can't instantiate them. What kind of class has no > instances? The Unicorn class perhaps? Well, the major example that comes to mind is the singleton class in Ruby :-) But I understand the misgivings. Matz has talked about making them some other kind of "class-like object" in the future. I'm not rooting for that, though. The reason I like having them be classes is the great simplicity of the whole design: you just insert the singleton class on the method search path, and it fits in so nicely. No need to explain (and I always find myself thinking in terms of explaining these things) a completely different entity for this one case. I suppose one could also say that it's the ultimate emblem of the class-based/prototype-based hybrid nature of Ruby: a class that expresses the liberation of the object from its class ancestry. David -- David A. Black dblack@wobblini.net