From: Ned Konz Date: 2002-06-14T01:19:47+09:00 Subject: The need for metaclasses (was Re: Ruby for jMax) On Thursday 13 June 2002 08:50 am, Kyle Rawlins wrote: > On Thu, Jun 13, 2002 at 11:09:10PM +0900, Fran�ois D�chelle wrote: > > Another point: it looks like metaclass do not fit into standard > > object oriented languages. May be an indication that it is not > > the right concept. I'm not sure what you mean by "standard object oriented languages". I didn't know there was such a thing. There are "popular" OO languages (by usage, by interest in the academic community, by marketing dollars spent, by magazine space, etc.). [snip] > Perhaps I misunderstood? Possibly it just worries me because I > rather like metaclasses and think that they're a good abstraction > for certain aspects of OO languages. There has been ongoing discussion about metaclasses over on comp.lang.smalltalk. And on the Squeak list, Alan Kay has expressed doubts about whether metaclasses were a good idea, given the difficulty of supporting them in the environment. At least in Smalltalk, metaclasses do a few things: * provide a namespace for otherwise global "loose" methods (especially constructors) * provide a namespace for otherwise global variables * hold class metadata (shape of instance variables, organization for browsers...) * hold compiled methods * hold selectors and their mapping to compiled methods * hold a reference to the superclass (am I missing anything?) All of these could be (and have been) done by separate reflection and namespace mechanisms without requiring metaclasses. For instance, one could use prototypes for constructor behavior. And separate "mirror" objects for reflection. These two are what the Self language did; Self did away with classes altogether. After all, classes are not essential for object-oriented programming. Though they've been a comfortable concept in many languages, all you really need for OO is objects. Inheritance, classes as objects, etc. aren't required. -- Ned Konz http://bike-nomad.com GPG key ID: BEEA7EFE