-
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?
.
please re-tag as [ILIAS]
Please read this paper of matz wich has an in depth analysis of the
problem space.
martinus
> Otherwise: who should take you serious?
Bwaaaahahahaaahaaahha-aaahhaahhahahahahaha... :)
--
Luc Heinrich - luc...@mac.com
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.
Matz should sue you for putting his name on that ;)
--
spooq
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 ruby...@ruby-lang.org, 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-----
I hope he does not :)
More information about the paper can be found here:
http://www.pdos.csail.mit.edu/scigen/
martinus
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 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]
.
> The diagram has evolved in this point:
> http://lazaridis.com/case/lang/ruby/
And it is still wrong in that respect.
> so, please show me how to play with those "metaclasses".
Request denied. Now go away.
> The diagram has evolved in this point:
Oops, you misspelled “diagramm”,
nikolai
--
Nikolai Weibull: now available free of charge at http://bitwi.se/!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
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 << Class; self; end ) # => #<Class:Class>
> 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
class<<Class;self;end
$ ruby -e 'p class<<Class;self;end'
#<Class:Class>
> 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
--
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.
>
>> the above diagramm shows a "(Class)", which is documented as a
>> "metaclass".
>>
>> How do I access this class?
>
> p( class << Class; self; end ) # => #<Class:Class>
ok.
>> the above diagramm shows a "(Object)", which inherits from "Class".
>>
>> how do I call "(Object).superclass"?
>
> p( class << Object; self; end.superclass ) # => Class
ok
> Regards,
> Pit
thank you for the compact and concise answer.
.
(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
.
>>> 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)
@Meta ||= (class<<self; self;end)
ok, with this change it seems to work.
> 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
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
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.
.
On 4/20/05, Ilias Lazaridis <il...@lazaridis.com> wrote:
the time budget for ruby is gone.
>
> sorry.
>
--
Bill Atkins
I'm probably going to be shot by the rest of the mailing list members for
continuing this, but I learned from this so hopefully others will as well:
irb(main):001:0> ObjectMetaClass = class<<Object;self;end
=> #<Class:Object>
irb(main):002:0> ObjectMetaClass.superclass
=> Class
irb(main):003:0> ClassMetaClass = class<<Class;self;end
=> #<Class:Class>
irb(main):004:0> ClassMetaClass.superclass
=> #<Class:Module>
irb(main):005:0> ClassMetaClass.superclass.superclass
=> #<Class:Object>
irb(main):006:0> ClassMetaClass.superclass.superclass.superclass
=> Class
irb(main):007:0> ObjectMetaClass.class
=> Class
irb(main):008:0> ClassMetaClass.class
=> Class
irb(main):009:0> ModuleMetaClass = class<<Module;self;end
=> #<Class:Module>
irb(main):010:0> ModuleMetaClass.superclass
=> #<Class:Object>
irb(main):011:0> ModuleMetaClass.superclass.superclass
=> Class
irb(main):012:0> ModuleMetaClass.class
=> Class
irb(main):013:0> StringMetaClass = class<<String;self;end
=> #<Class:String>
irb(main):014:0> StringMetaClass.superclass
=> #<Class:Object>
irb(main):015:0> StringMetaClass.superclass.superclass
=> Class
irb(main):016:0> StringMetaClass.class
=> Class
irb(main):017:0> class Object;def metaclass;class<<self;self;end;end;end
=> nil
irb(main):018:0> Object.metaclass
=> #<Class:Object>
irb(main):019:0> Class.metaclass
=> #<Class:Class>
I feel this proves the diagram shown in "ri Class" is correct. Not that
*I* ever had any doubt.
Ryan
>>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?
I think he was not expecting to get an answer to this question. When
other languages have constructs like this the answer usually is "You
can't do this" which would have given him a perfect reason for
bitch-slapping Ruby. It didn't work out and I think he is not really
interested in the solution as long as there is one.
> see an compact document about terminology and delayed recognition:
>
> http://lazaridis.com/core/project/gnu_gpl.html
This page is incorrect.
Also, it is incomplete.
(Ok, I tried hard, but I feel affiliated to GNU and cannot let this
stay as it is.)
--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org
no, this just prove that you can play with the irb.
> Not that *I* ever had any doubt.
>
> Ryan
.
Well, see the thread
and browse it 'till 8th post (which is avaiable separately as
http://groups-beta.google.com/group/comp.lang.ruby/msg/3aa2dbdfa6fbdbd5
).
This shows that you got your concise and compact answer already on 5th
of April, more than two weeks before. And no trace of the big mess which
your thread evolved into appears at this point, so don't say you were
overwhelmed then.
And you got the same answer a zillion times since then, in zillion
different forms.
You were just too fcknuig lazy to take the effort of understanding these
answers (or ask properly if you don't succeed).
You seem to work in a way that you browse through the answers quickly;
upon doing so some of the sentences ring a bell, others not, and that's
it. You don't seem to give a second chance to the posts, rather iterate
the above procedure, by asking essentially the same again. Bad, bad.
I understand you don't wanna learn ruby just evaluate it, but the above
sketched work method doesn't seem to be fruitful in this case either.
And btw, concerning your "Meta" method implementation, get rid of the
"@Meta ||=" part. It's not a gain in efficency, but a pain for the eye.
Csaba