[EVALUATION] - E03c - The Ruby Object Model (Revised Documentation)

I

Ilias Lazaridis

Lionel said:
Ilias Lazaridis a écrit :

I can.

-

But there are other ways of asking, you know... :(

there are other ways of answering, too.
-

I'll give it a try: the documentation "ri Class" gives is not wrong at
all. Maybe not complete, but not wrong.

it's incomplete, wrong and missleading.
-

In "ri Class" text, if you replace references to "metaclasses" (which
are said to be between parentheses) by "singleton method placeholders",
perhaps it becomes clearer?

no, then it becomes completely confusing.
-

I remember that what was disturbing you was the stuff about metaclasses.
I told you ruby invite you to think more in terms of singleton method
than in terms of metaclasses. But it seems that you ignore what are
singleton methods.

of course i ignore them.

they are not relevant when reviewing ruby's oject-model.
-

Have you ever evaluated some classless OO langages? I know some: IO (
http://www.iolanguage.com/ ), Self ( http://c2.com/cgi/wiki?SelfLanguage
) and REBOL (rebol is not basically OO, but its OO part is classless.
http://www.rebol.com/ ). If you would, the concept of singleton method
would be far easier to understand for you. (this is actually how I
understood that concept)

[will possibly take a look at them shortly]
-

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

Your UML diagram of ruby object model is hard to read, and probably
wrong. The separation between classes in memory and in source code is
totally confusing.

the seperation exist in reality (and in the "ri class" documentation).

additionally: It was neccessary for my understanding process.

the next version (1.1), the diagramm will be simplified (possibly in a
few hours, if the stuff has passed).
In ruby, classes *are* objects.

yes, but there is still a class definition.
Learn more about
classless languages, and it should be far easier to understand these
concepts.

this is not relevant to understand ruby's Object Model.

I just need a (correct) UML diagram to understand Ruby's Object Model.
There is another evident mistake in your UML diagram. Object doesn't
inherit from nil, nil is a literal and an instance of NilClass which
inherit from Object.

you are wrong:

irb(main):001:0> Object.superclass
=> nil
irb(main):002:0> nil.class
=> NilClass

[btw: to simplify the analysis, I've stopped exporing "nil" at that point]
-

I tried my best, I can't say anymore. Please, don't ask me for lengthy
exhausting explanations. Try the languages I told you about, they are
really worth it.

will possibly do this shortly.
-

Have a nice day.

--
Lionel Thiry

PS: Please, anybody, do not blame me for anwsering this post. Do not
blame me for imitating Lazaridis posting. Do not blame me for trying to
be nice.

..
 
I

Ilias Lazaridis

tsuraan said:
Scary... Before I even clicked the link, I was sure of which one you
were referring to.

This technique leads to uncontrolled threads, full of off-topic ranting.

that's why I don't use it [at least not here within comp.lang.ruby]

..
 
J

Jim Weirich

you are wrong:

irb(main):001:0> Object.superclass
=> nil

The documentation for superclass clearly states that it returns the superclass
of its target, or nil.

In this case it returns nil because Object does not have a superclass, i.e. it
does not inherit from anything.
 
I

Ilias Lazaridis

Jim said:
The documentation for superclass clearly states that it returns the superclass
of its target, or nil.

In this case it returns nil because Object does not have a superclass, i.e. it
does not inherit from anything.

In context of an Language Object Model:

Object inherits from "nil".

"nil" is represented by an _instance_ of class "NilClass".

I've drawn this instance "nil" into the diagram.

[possibly it will be removed with the next revision]

-

Nil is a terribly confusing topic, thus I would prefere to keep is out
of the currect topic.

You can review an old thread about smalltalk's Nil:

comp.lang.smalltalk > ST - The Loneliness of Nil
http://groups-beta.google.com/group/comp.lang.smalltalk/msg/f7f017a49e6268e1

..
 
S

Saynatkari

Le 19/4/2005 said:
In context of an Language Object Model:

Object inherits from "nil".

Er, no. Object does not inherit. As was pointed out to
you, #superclass just happens to return nil to signify
there is no superclass.
"nil" is represented by an _instance_ of class "NilClass".

I've drawn this instance "nil" into the diagram.

[possibly it will be removed with the next revision]

-

Nil is a terribly confusing topic, thus I would prefere to keep is out
of the currect topic.

Why is it confusing? nil is 'nothing'.
You can review an old thread about smalltalk's Nil:

comp.lang.smalltalk > ST - The Loneliness of Nil
http://groups-beta.google.com/group/comp.lang.smalltalk/msg/f7f017a49e6268

E
 
M

Martin DeMello

Ilias Lazaridis said:
In context of an Language Object Model:

Object inherits from "nil".

Object does *not* inherit from nil. Object.superclass returns 'nil'
because Object has no superclass.

martin
 
J

Jim Weirich

In context of an Language Object Model:
Object inherits from "nil".

Nothing can inherit from nil, for nil is not an instance of Class... as
demonstrated below.
TypeError: superclass must be a Class (NilClass given)
from (irb):10

In the context of the Ruby Object Model, Object has not superclass and does
not inherit from anything.

Please remove the inaccuracies in your Language Object Model.
 
M

mark sparshatt

Ilias said:
Christian said:
I do not see what's wrong here, can you explain?


definitive errors:

a) not all arrows represent inheritance, just the verticals.

b) the relation "(Object)"---[inherits from]--->"Class" is false.

correct: "(Object)"---[inherits-from]------->nil

As other people have pointed out this is wrong since nothing can inherit
from nil, since it isn't a class.

The mistake you're making is that (Object) doesn't represent an instance
of Object. It represents Object's metaclass.

Using _why's metaid library

Object.metaclass.superclass #=> Class

So the ruby documentation is correct, (Object) does inherit from Class
or

correct: "(Object)"---[is-an-instance-of]--->Class

This is correct. (Object) both inherits from and is an instance of Class.
-

and finally:

the diagramm gives the impression, that "Object" and "(Object)" (etc.)
are both classes,

Object and (Object) are both classes.
which is of course false. There is a "definition" and
an "(instance)".

no there is a "class" and a (metaclass)
 
I

Ilias Lazaridis

Jim said:
Nothing can inherit from nil, for nil is not an instance of Class... as
demonstrated below.

you reverse things.
TypeError: superclass must be a Class (NilClass given)
from (irb):10

this is irrelevant.
In the context of the Ruby Object Model, Object has not superclass and does
not inherit from anything.

it inherits from nothing, which is represented by "nil", which is a
'living' object, which is an instance of class NilClass, which inherits
from Object.
Please remove the inaccuracies in your Language Object Model.

I will add the above describewd circularity to the new diagram.

then please review it again.

..
 
I

Ilias Lazaridis

Saynatkari said:
Er, no. Object does not inherit. As was pointed out to
you, #superclass just happens to return nil to signify
there is no superclass.

you can express this as "Object inherits from nil".

which is similar to "Object inherits from nothing".

but the second is not true, as .superclass returns an object, which is
"nil".
"nil" is represented by an _instance_ of class "NilClass".

I've drawn this instance "nil" into the diagram.

[possibly it will be removed with the next revision]

-

Nil is a terribly confusing topic, thus I would prefere to keep is out
of the currect topic.

Why is it confusing? nil is 'nothing'.

in context of Language Object models.

see the thread below:

..
 
M

Martin DeMello

Ilias Lazaridis said:
it inherits from nothing, which is represented by "nil", which is a
'living' object, which is an instance of class NilClass, which inherits
from Object.

With apologies to Martin Gardner,

1. Nothing is better than eternal happiness
2. A ham sandwich is better than nothing
3. Therefore, a ham sandwich is better than eternal happiness

martin
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: - E03c - The Ruby Object Model (Revised Documentation)"

|>>Object inherits from "nil".
|>
|> Er, no. Object does not inherit. As was pointed out to
|> you, #superclass just happens to return nil to signify
|> there is no superclass.
|
|you can express this as "Object inherits from nil".

Don't, please. It is confusing.

matz.
 
I

Ilias Lazaridis

Yukihiro said:
Hi,

In message "Re: - E03c - The Ruby Object Model (Revised Documentation)"

|>>Object inherits from "nil".
|>
|> Er, no. Object does not inherit. As was pointed out to
|> you, #superclass just happens to return nil to signify
|> there is no superclass.
|
|you can express this as "Object inherits from nil".

Don't, please. It is confusing.

I am myself confused, but will shortly be in clarity.

for now I can only rephrase to:

"class Object inherits from nothing (represented by object nil)"

..
 
I

Ilias Lazaridis

Martin said:
With apologies to Martin Gardner,

1. Nothing is better than eternal happiness
2. A ham sandwich is better than nothing
3. Therefore, a ham sandwich is better than eternal happiness

martin

thank's for the reminder.

time to eat.

after this (~ 2 to 3 hours), I'll publish the 1.1 version here:

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

..
 
P

Peter Reilly

Ilias said:
I am myself confused, but will shortly be in clarity.

for now I can only rephrase to:

"class Object inherits from nothing (represented by object nil)"

Very zen like!

Peter
 
M

mark sparshatt

Ilias said:
I've not said that "Object inherits from Class nil".

I've said: Object inherits from nil

which is true.
Surely if Object inherits from nil then Object should inherit all of
nil's methods

nil.methods - Object.methods #=> ["&", "|", "^", "to_i", "to_s"]

Object.to_s #=> NoMethodError: undefined method 'to_s' for Object:Class

Since Object doesn't inherit all of nil's methods I don't see how it can
make sense to say that Object inherits from nil.
 
R

Ralf Müller

With apologies to Martin Gardner,

1. Nothing is better than eternal happiness
2. A ham sandwich is better than nothing
3. Therefore, a ham sandwich is better than eternal happiness

martin

And that's what the whole things is about.
Many thanks to you martin. I can't guess a better summary.
 
T

ts

I> Possibly the same bot has generated the the "ri class" documentation.

the schema in "ri class" was created by matz.


Guy Decoux
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top