From: Robert Klemme Date: 2005-04-09T00:19:42+09:00 Subject: Re: [EVALUATION] - E03b - The Ruby Object Model "Csaba Henk" schrieb im Newsbeitrag news:slrnd5d5vm.crg.csaba@ms0.math.ucalgary.ca... > On 2005-04-05, Lionel Thiry wrote: > > Most of the time, everything goes in ruby as if there weren't any kind of > > metaclasses. For exemple, you cannot explicitely create your own metaclasses: > > > > class MyMetaClass < Class > > end > > > > It raises the exception: > > metaclass.rb:1: can't make subclass of Class (TypeError) > > Hmm, the rigor of the interpreter here is somewhat loose. You can > subclass Class, just not as you tried. > > MyMetaClass = Class.new Class > MyMetaClass.ancestors > # => [MyMetaClass, Class, Module, Object, Kernel] > > This works just fine. However, it's not too consistent altogether... The question is, what does one gain by subclassing Class? You cannot create instances (i.e. classes) of it: >> Foo = MyMetaClass.new TypeError: wrong instance allocation from (irb):5:in `new' from (irb):5 >> Foo = MyMetaClass.allocate TypeError: wrong instance allocation from (irb):6:in `allocate' from (irb):6 Cheers robert