[EVALUATION] - E03d - The Ruby Object Model (End Game)
http://groups-beta.google.com/group/comp.lang.ruby/msg/ea9da543dc256b42
···
-
The above thread has led to this code:
class Class
def Meta()
@Meta ||= (class<<self;self;end)
end
end
which is modified here to:
class Object
def sso()
@sso ||= (class<<self;self;end) # see code below
end
end
simplified:
def sso()
unless @sso
@sso = (class<<self; self; end) #
end
@sso
end
-
sso = Specializing Singleton Object
-
The sso contains definitions (methods, attributes, constants) which specialize the behaviour of its carrying object.
The "sso" of a "class object" is used to specialize the behaviour of the class (against Class).
-
The sso's are essentially internal implementation details, although they are accessible (see code above).
The sso's are _not_ part of the Ruby Object Model (e.g. inheritance hierarchy).
-
As stated before, the following documentation is false:
cmd:> ri Class
"Classes, modules, and objects are interrelated. In the diagram that
follows, the arrows represent inheritance, and the parentheses
meta-classes. All metaclasses are instances of the class `Class'."
+------------------+
> >
Object---->(Object) |
^ ^ ^ ^ |
> > > > >
> > +-----+ +---------+ |
> > > > >
> +-----------+ | |
> > > > >
+------+ | Module--->(Module) |
> > ^ ^ |
OtherClass-->(OtherClass) | | |
> > >
Class---->(Class) |
^ |
> >
+----------------+
-
a) The term "meta-classes" is false.
Correction: "specializing-singleton-objects"
b) vertical arrows do not represent inheritance
e.g.: Object---->(Object)
Correction: Object-----(Object)
c) the classes in "()" do not belong to the object model
Correction: remove (showcase sso in seperate topic)
-
My final questions are basicly:
* Ruby is OO. Why is the sso not directly accessible?
* Who has written the "ri Class" documentation?
* Can I expect an apology for this false documentation?
-
http://lazaridis.com/case/lang/ruby
..