[EVALUATION] - E03d - The Ruby Object Model (End Game)

I

Ilias Lazaridis

[EVALUATION] - E03c - The Ruby Object Model (Revised Documentation)
http://groups-beta.google.com/group/comp.lang.ruby/msg/b72b4a3bfd81a48e?hl=en

-

the above thread went a little out of control.

The mostly discussed point (inherits from nil) has evolved and

please focus on the essence:

which is the term "metaclass"

-

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) |
^ |
| |
+----------------+

-

The above documentation is false.

-

The mentioned metaclasses like "(Class)" are not existent and not
accessible whilst using standard Class/Object mechanisms.

The term "metaclasses" could be exchanged with e.g. "internal
representations of class definitions" or anything adequate.

This is _not_ the same with a metaclass (which must be a _class_).

-

See the UML diagramm "TheRubyObjectModel" (V1.3) for a corrected
clarifying version:

http://lazaridis.com/case/lang/ruby/

-
-
-

If I am wrong, please show me how to access the metaclass:

ClassMetaClass = Class.???

ClassMetaClass.<class operations / access>

-

please avoid usage of libraries, excessive code etc. We are talking
about an oject-model, which should simply... exist!

so, which is the cleanes and simplest way to get access to the "metaclass"?

-

I like to remind you, that evaluators coming from C++, Smalltalk, Java
etc. are not intrested in the specialities of a language (especially if
they are not necessary).

The developers and the community should be capable to use
standard-terminology to explain the ruby model.

Otherwise: who should take you serious?

..
 
G

gabriele renzi

Martin Ankerl ha scritto:
Please read this paper of matz wich has an in depth analysis of the
problem space.

http://qurl.net/dx

martinus

great paper!

Btw, please guys, if you don't like ilias just ignore him. I mean,
almost everything from him is clearly tagged as [evaluation] and is
quite easy to snip withouth making noise.
 
G

Gary Lowder

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

gabriele renzi wrote:
|
|
| Btw, please guys, if you don't like ilias just ignore him. I mean,
| almost everything from him is clearly tagged as [evaluation] and is
| quite easy to snip withouth making noise.

But that's just the latest thread, I've got ilias as: [USENET], [IDE],
EO3c, [ADVOC] and [Ilias|Troll|LOON] (my fav, and authored by Ilias
himself).

On one hand it's fun to see the troll dance, but on the other it's
sickening to see people spend effort on an answer to insane questions.

OH, and I'm not actually feeding the troll at the moment, I'm taking
great pleasure in typing this (though sorry for that one more email I
guess).

Gary.

"Ilias Lazaridis is a troll and is being ignored by this
community on purpose. Any information from Lazaridis should
be considered to be either incorrect or inaccurate.

If you came across this Lazaridis post in a search on a
ruby-related question, we advise you to post your question
to comp.lang.ruby (or (e-mail address removed), the mirrored
mailing list), or try another search result.

Regards,
~ ruby-talk- and comp.lang.ruby users"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCZghJuXzcPSKHG/URAgenAKC0kmIArc4RKTxL3526ASS/YuFfsgCfcGgC
rMBWxRRgBYlS7KbtiCFZQeI=
=mCSq
-----END PGP SIGNATURE-----
 
M

Mark Hubbart

[EVALUATION] - E03c - The Ruby Object Model (Revised Documentation)
http://groups-beta.google.com/group/comp.lang.ruby/msg/b72b4a3bfd81a48e?hl=en

-

the above thread went a little out of control.

The mostly discussed point (inherits from nil) has evolved and

please focus on the essence:

which is the term "metaclass"

-

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) |
^ |
| |
+----------------+

-

The above documentation is false.

Not so. It is perhaps a bit unclear, but not incorrect. Also, the
concepts themselves a bit difficult to fully comprehend, but that's
how these things work, when you get into metametaclasses and so forth.

I should also add my voice to the throng complaining about the
'Object.superclass == nil' issue. Object's superclass is not nil. It
is not *represented* by nil, and nil has absolutely nothing to do with
Object's superclass.

Object *has no superclass*. All other classes have them, though, and
there's a method (superclass) that returns the superclass. since
Object is an instance of Class, it inherits this method. So there are
three possible things that could be done:
- Make Object.superclass raise an error, perhaps NoMethodError
- Make Object.superclass return Object
- Make Object.superclass return nil

It would seem they chose the third option. I would assume that raising
an error was out of the question, and making the method return Object
would be inaccurate. So nil was chosen.
The mentioned metaclasses like "(Class)" are not existent and not
accessible whilst using standard Class/Object mechanisms.

Yes, they are accessible. Metaclasses are implemented in Ruby
(essentially) as singleton classes. All meta-class objects are
instances of the Class metaclass, and are accessible:
the expression:
23.class
has the value of:
Fixnum

Fixnum is the way you would refer to the metaclass. It holds all the
methods that Fixnum instances have, as well as class variables and
constants.

Note that I'm not referring to internal representation and structures,
which are irrelevant to this discussion.
The term "metaclasses" could be exchanged with e.g. "internal
representations of class definitions" or anything adequate.

This is _not_ the same with a metaclass (which must be a _class_).

I'm not sure what you are saying here. A metaclass is a template for
creating objects. Terminology is irrelevant. Function is.

Why do you say that ruby's metaclass objects are not true metaclasses?
-

See the UML diagramm "TheRubyObjectModel" (V1.3) for a corrected
clarifying version:

http://lazaridis.com/case/lang/ruby/

-
-
-

If I am wrong, please show me how to access the metaclass:

ClassMetaClass = Class.???

ClassMetaClass.<class operations / access>

Class's metaclass is Class. It's the stopping point - there has to be
one. If there wasn't one:

Class.class => MetaClass
MetaClass.class => MetaMetaClass
[infinite progression detected]


It's easiest to understand Ruby's object model this way: Everything is
an object *first*, and a class member second. Metaclasses are all
objects of class Class. Metaclasses have singleton methods added to
them, and internal method tables that define the template for objects
created from them.

You can even, for the most part, create your own implementation of
Class in Ruby. just create an object, and add singleton methods. It
will work just the same as ruby's own class, minus a little syntactic
sugar.

Someone mentioned that you need to learn more about Ruby's singleton
methods. They were correct. Understanding Ruby's singleton method
concept is *essential* to full understanding of the object model,
imho.

-

Object, the most generic metaclass for objects, is an object. If you
check the ancestors of Object's class, you will find Object listed.
This is because Class is a subclass of Object itself. Object is where
are things, classes and objects are derived from. In Ruby, Object is
God.

There is a nice discussion of this here[1], especially in the third
chapter. It gets into metaclasses, specifically how they are used in
Ruby.

[1] http://www.visibleworkings.com/little-ruby/

PS
please don't attack me for feeding the troll. just add this thread to
your filter :)
 
I

Ilias Lazaridis

Mark said:
[EVALUATION] - E03c - The Ruby Object Model (Revised Documentation)
http://groups-beta.google.com/group/comp.lang.ruby/msg/b72b4a3bfd81a48e?hl=en

-

the above thread went a little out of control.

The mostly discussed point (inherits from nil) has evolved and

please focus on the essence:

which is the term "metaclass"

-

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) |
^ |
| |
+----------------+

-

The above documentation is false.

Not so. It is perhaps a bit unclear, but not incorrect. [...]

I should also add my voice to the throng complaining about the
'Object.superclass == nil' issue.
[...]

please.

The diagram has evolved in this point:

http://lazaridis.com/case/lang/ruby/
The mentioned metaclasses like "(Class)" are not existent and not
accessible whilst using standard Class/Object mechanisms.
[...]
If I am wrong, please show me how to access the metaclass:

ClassMetaClass = Class.???

ClassMetaClass.<class operations / access>

Class's metaclass is Class.
[...]

"Class" is the _class_ of "Class", not its metaclass.

-

the above diagramm shows a "(Class)", which is documented as a "metaclass".

How do I access this class?

-

the above diagramm shows a "(Object)", which inherits from "Class".

how do I call "(Object).superclass"?

-

ruby is about fun and simplicity in programming?

so, please show me how to play with those "metaclasses".

[please without essay's]

..
 
P

Pit Capitain

Ilias said:
[please without essay's]

Try to carefully read and understand the answers others have already
given to your previous questions. Then you should be able to come up
with the following code by yourself.
the above diagramm shows a "(Class)", which is documented as a "metaclass".

How do I access this class?

p( class said:
the above diagramm shows a "(Object)", which inherits from "Class".

how do I call "(Object).superclass"?

p( class << Object; self; end.superclass ) # => Class

Regards,
Pit
 
C

Carlos

2005-04-20 11.24 CEST] said:
"Class" is the _class_ of "Class", not its metaclass.

-

the above diagramm shows a "(Class)", which is documented as a "metaclass".

How do I access this class?

class<<Class;self;end

$ ruby -e 'p class<<Class;self;end'
# said:
the above diagramm shows a "(Object)", which inherits from "Class".

how do I call "(Object).superclass"?

class<<Object;self;end

$ ruby -e 'p class<<Object;self;end.superclass'
Class

--
 
I

Ilias Lazaridis

Pit said:
Ilias said:
[please without essay's]

Try to carefully read and understand the answers others have already
given to your previous questions.

Subjecting the old thread, I'm currently on inhibition, due to large
amounts of overinformation.
Then you should be able to come up
with the following code by yourself.


p( class << Class; self; end ) # => #<Class:Class>
ok.


p( class << Object; self; end.superclass ) # => Class
ok

Regards,
Pit

thank you for the compact and concise answer.

..
 
I

Ilias Lazaridis

Carlos said:
2005-04-20 11.24 CEST] said:
"Class" is the _class_ of "Class", not its metaclass.

-

the above diagramm shows a "(Class)", which is documented as a "metaclass".

How do I access this class?

class<<Class;self;end

$ ruby -e 'p class<<Class;self;end'
# said:
the above diagramm shows a "(Object)", which inherits from "Class".

how do I call "(Object).superclass"?


class<<Object;self;end

$ ruby -e 'p class<<Object;self;end.superclass'
Class

(class<<Object; self; end).superclass

ok, fine.

-

How do I include the construct:

(class<<Object; self; end)

conveniently into the definition of "Class"?

I like to have <class>.Meta available in each class.

-

I'm a newcomer, my try is this one:

class Class
def Meta()
@Meta ||= (class<<self.class;self;end)
end
end

but it fails

p Talker.Meta.object_id => 20763792
p (class<<Talker;self;end).object_id => 20679384

..
 
I

Ilias Lazaridis

Ilias said:
Carlos wrote: [...]
class<<Object;self;end

$ ruby -e 'p class<<Object;self;end.superclass'
Class

(class<<Object; self; end).superclass

ok, fine.

-

How do I include the construct:

(class<<Object; self; end)

conveniently into the definition of "Class"?

I like to have <class>.Meta available in each class.

-

I'm a newcomer, my try is this one:

class Class
def Meta()
@Meta ||= (class<<self.class;self;end)
@Meta ||= (class<<self; self;end)

ok, with this change it seems to work.
 
I

Ilias Lazaridis

Ilias Lazaridis wrote:
[...]
If I am wrong, please show me how to access the metaclass:

ClassMetaClass = Class.???

ClassMetaClass.<class operations / access>

-

please avoid usage of libraries, excessive code etc. We are talking
about an oject-model, which should simply... exist!

so, which is the cleanes and simplest way to get access to the "metaclass"?

class Class
def Meta()
@META ||= (class<<self;self;end)
end
end

class Talker
end

puts "\n----- verifying validity of MetaClass Access ----------\n"

p Talker.Meta.object_id
p (class<<Talker;self;end).object_id
p Class.Meta.object_id
p (class<<Class;self;end).object_id
p Module.Meta.object_id
p (class<<Module;self;end).object_id
p Object.Meta.object_id
p (class<<Object;self;end).object_id
p NilClass.Meta.object_id
p (class<<NilClass;self;end).object_id

puts "\n----- start playing with the MetaClasses ---------------\n"

puts "\nSuperClasses:\n"
p Object.Meta.superclass
p Module.Meta.superclass
p Class.Meta.superclass
p Talker.Meta.superclass

puts "\nClasses:\n"
p Object.Meta.class
p Module.Meta.class
p Class.Meta.class
p Talker.Meta.class

I like to remind you, that evaluators coming from C++, Smalltalk, Java
etc. are not intrested in the specialities of a language (especially if
they are not necessary).

The developers and the community should be capable to use
standard-terminology to explain the ruby model.

The last step would be, to verify the used terminology.

"metaclass" and "singleton" seems to be used incorrect.

[but at this point, I'm exhausted by the excessive off-topic's.]

-

see an compact document about terminology and delayed recognition:

http://lazaridis.com/core/project/gnu_gpl.html
Otherwise: who should take you serious?

..
 
C

Chris Pine

How do I include the construct:
(class<<Object; self; end)

conveniently into the definition of "Class"?

Oh. My. God.

I can't believe you just asked that. How many thousands of lines ago
were people urging you PLEASE go read something really intelligent
answering exactly your questions?

http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html

Look, I know you won't read it, but at least try to get 1/4 of your
way through just the first code example.

Go ahead.

Do you see it? Does it look familiar?? Do you think that, just
maybe, the people on this list are actually really, really helpful
people? Maybe you should read the help they try to give you?

You speak of efficiency. Well,
let-me-tell-you-something-about-efficiency, mister: THESE LAST
HUNDRED POSTS WERE NOT AN EFFICIENT WAY OF OBTAINING THE KNOWLEDGE YOU
DESIRE! In fact, I can not imagine a *less* efficient (but ultimately
successful) way to do so.

Perhaps it would help you to view this mailing list as a system, not
as a collection of humans like yourself. (In fact, I know of no one
quite like you... I mean that not insultingly, nor complimentarily,
just factually.) This system can be used effectively, or poorly. If
you choose to use it, you might as well try to use it effectively.

Here are some efficiency tips for you:
1. Read the answers other people give you. Assign them a high
probability of being right, and try to adjust your own
understanding accordingly.
2. Don't tell them they are wrong. *Especially* when they
are not! (But find better ways to tell them, even if they are wrong.)
3. Admit when you have made a mistake. This one
is tough, but it's *really* important. Otherwise efficiency
drops way off after that point.

And you have made mistakes. For example, you claimed on several
occasions that metaclasses don't exist. Now you know they do. I'm
not saying it's your fault (though the documentation is right there in
ri class, but whatever), just that you said something false to
someone. It's not about fault, or admitting fault; it's about fact.

If you want that person to help you in the future, I suggest
apologizing. Again, if it helps to think of the ML as a system, and
apologies the grease, that's fine. But I think it's pretty clear that
your dealings with the ML have been far less effective than most
people's.

I think some self-evaluation, at least in this respect, is in order.

Chris
 
I

Ilias Lazaridis

Chris said:
Oh. My. God.

I can't believe you just asked that.
[...]

of course.

and I got the concise and compact answer.

Which led me to the simple solution.

[btw: the thread "[ANN] Article: Seeing Metaclasses Clearly" came 2
weeks after my initial thread. But the documentation is anyway to complex.]

-

And I know now:

"ri class" documentation is missleading.

and: it is false.

[but I'm to exhausted to elaborate on this]

-

the time budget for ruby is gone.

sorry.

..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top