From: Csaba Henk Date: 2005-04-09T17:14:40+09:00 Subject: Re: [EVALUATION] - E03b - The Ruby Object Model On 2005-04-08, Robert Klemme wrote: > > "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: That's good to know, but this question is another question. What I was wandering about is that why it is so that you can't subclass Class if you use the syntax "class Foo < Bar" but you can do it as "Foo = Class.new Bar". Considering the effectiveness of subclassing class: most of this stuff you'd want to achieve this way can be done by just subclassing Module. You'll be free to implement "new" as you want (although you can't use "super" in this definiton, you can do "o = Object new; o.extend Foo"). Csaba