There are nice diagrams of this relationship in Programming Ruby (Chapter 24: Objects and Classes).
or you can just use ri:
ri Class
generates an ASCII version of the diagrams.
George.
There are nice diagrams of this relationship in Programming Ruby (Chapter 24: Objects and Classes).
or you can just use ri:
ri Class
generates an ASCII version of the diagrams.
George.
Robert Klemme wrote:
"Ilias Lazaridis" <ilias@lazaridis.com> schrieb im Newsbeitrag
news:d2r96v$c9c$1@usenet.otenet.gr...
[...]
I've understood now the problem.
-
The Ruby Object Model does not contain reflective MetaClasses, which
would enable to apply metadata even to methods.I'm not sure what exactly you mean by this. You can indeed access classes
in Ruby. So I'd say there *are* MetaClasses. It's just that there is no
persistent representation of methods which you could augment with
additional data.
[...] - (some examples)
ok, there are metaclasses, which are not fully(!) reflective (as already showcased due to the missing possiility to recreate the class-definition).
[E.g. Smalltalks object model is fully reflective (classes are instances of metaclasses).]
A Visual representation of the Relevant Ruby Object Model (e.g. with
UML) would be very helpfull to understand this immediately.I don't know whether such thing exists, but the concept is usually easy
grasped IMHO. Try to play a bit with classes in IRB - that helped me a
lot. Note especially methods #class, #ancestors and #superclass.
[I must close this thread here - I've dived already too deep]
One could possibly ask in the developers list.
This documentation should be in a central place on ruby-lang.org.
An language-object-model should be document clearly.
..
Csaba Henk wrote:
A Visual representation of the Relevant Ruby Object Model (e.g. with UML) would be very helpfull to understand this immediately.
You can find something like this at
class Class - RDoc Documentation -- though not UML just
simple ascii art.
ok, but this is too less information
(but it shows the involved classes)
You might as well enjoy "A Little Ruby, A Lot of Objects" by Brian
Marick (http://www.visibleworkings.com/little-ruby/\). In the 3rd chapter
a visualization of the Ruby object model is worked out in a
step-by-step, deductive way (which is the methodology of the whole
work).
and this is too much information for me.
Possibly I will create an UML diagramm.
..
Csaba Henk wrote:
The Ruby Object Model does not contain reflective MetaClasses, which would enable to apply metadata even to methods.
You can attach metadata to a certain method object, it's just not what
[...] - (thorough elaboration)
Huh, I hope it's not too messy.
I will review the whole thread again (in a few days) and produce an updated template.
..
"Ilias Lazaridis" <ilias@lazaridis.com> schrieb im Newsbeitrag
news:d2rgtn$gaf$1@usenet.otenet.gr...
Robert Klemme wrote:
> "Ilias Lazaridis" <ilias@lazaridis.com> schrieb im Newsbeitrag
> news:d2r96v$c9c$1@usenet.otenet.gr...
[...]>>I've understood now the problem.
>>
>>-
>>
>>The Ruby Object Model does not contain reflective MetaClasses, which
>>would enable to apply metadata even to methods.
>
> I'm not sure what exactly you mean by this. You can indeed access
classes
> in Ruby. So I'd say there *are* MetaClasses. It's just that there is
no
> persistent representation of methods which you could augment with
> additional data.
[...] - (some examples)ok, there are metaclasses, which are not fully(!) reflective (as already
showcased due to the missing possiility to recreate the
class-definition).
[E.g. Smalltalks object model is fully reflective (classes are instances
of metaclasses).]
If that's the criterion I'd say that is indeed fully reflective:
class Foo;end
=> nil
Foo.class
=> Class
Foo.kind_of? Class
=> true
Foo.kind_of? Module
=> true
Class === Foo
=> true
Module === Foo
=> true
Foo.class.ancestors
=> [Class, Module, Object, Kernel]
In spite of that you cannot recreate a class definition because you cannot
extract method bodies from the meta data. All you get is method names via
#instance_methods and their arity. Does Smalltalk provide more?
Cheers
robert
George Moschovitis wrote:
There are nice diagrams of this relationship in Programming Ruby (Chapter 24: Objects and Classes).
Is this book available online?
or you can just use ri:
ri Class
generates an ASCII version of the diagrams.
where do i use it?
George Moschovitis wrote:
There are nice diagrams of this relationship in Programming Ruby (Chapter 24: Objects and Classes).
Is this book available online?
The first edition of the book (now in its second edition) is available online, but the figures aren't in it. They are what you are after.
or you can just use ri:
ri Class
generates an ASCII version of the diagrams.where do i use it?
ri should be installed with Ruby. The documentation may or may not have been, depending on how you installed Ruby. If it is installed, typing "ri Class" at the command-line will fetch the document.
I'll inline the document George mentioned below, for reference, but I don't personally feel it's as helpful as the figures in Programming Ruby.
James Edward Gray II
-------------------------------------------------- Class: Class < Module
Classes in Ruby are first-class objects---each is an instance of
class Class.
When a new class is created (typically using class Name ... end),
an object of type Class is created and assigned to a global
constant (Name in this case). When Name.new is called to create a
new object, the new method in Class is run by default. This can be
demonstrated by overriding new in Class:
class Class
alias oldNew new
def new(*args)
print "Creating a new ", self.name, "\n"
oldNew(*args)
end
end
class Name
end
n = Name.new
produces:
Creating a new Name
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'.
On Apr 4, 2005, at 9:04 AM, Ilias Lazaridis wrote:
+------------------+
> >
Object---->(Object) |
^ ^ ^ ^ |
> > > > >
> > +-----+ +---------+ |
> > > > >
> +-----------+ | |
> > > > >
+------+ | Module--->(Module) |
> > ^ ^ |
OtherClass-->(OtherClass) | | |
> > >
Class---->(Class) |
^ |
> >
+----------------+
------------------------------------------------------------------------
Class methods:
new
Instance methods:
allocate, inherited, initialize_copy, new, superclass
[...]
The Ruby Object Model does not contain reflective MetaClasses, which
would enable to apply metadata even to methods.
[...]
ok, there are metaclasses, which are not fully(!) reflective (as already
showcased due to the missing possiility to recreate the class-definition).[E.g. Smalltalks object model is fully reflective (classes are instances
of metaclasses).]If that's the criterion I'd say that is indeed fully reflective:
[...] - (some examples)
if ruby _is_ fully reflective, than please provide the code for "class definition recreation"
http://lazaridis.com/case/lang/ruby.html#sayYourClassDefinition
=> [Class, Module, Object, Kernel]
In spite of that you cannot recreate a class definition because you cannot
extract method bodies from the meta data. All you get is method names via
#instance_methods and their arity. Does Smalltalk provide more?
yes.
I've quickly found this here, which expresses the relevant points:
http://www.zenspider.com/Languages/Smalltalk/VsJava.html
[but please let's close this subthread, as I move out of topic and out of time.]
..
"Ilias Lazaridis" <ilias@lazaridis.com> schrieb im Newsbeitrag
news:d2rjbt$qs3$1@usenet.otenet.gr...
[...]
>>>>The Ruby Object Model does not contain reflective MetaClasses, which
>>>>would enable to apply metadata even to methods.
[...]>>ok, there are metaclasses, which are not fully(!) reflective (as
already
>>showcased due to the missing possiility to recreate the
class-definition).
>
>>[E.g. Smalltalks object model is fully reflective (classes are
instances
>>of metaclasses).]
>
> If that's the criterion I'd say that is indeed fully reflective:
[...] - (some examples)if ruby _is_ fully reflective, than please provide the code for "class
definition recreation"http://lazaridis.com/case/lang/ruby.html#sayYourClassDefinition
> => [Class, Module, Object, Kernel]
>
> In spite of that you cannot recreate a class definition because you
cannot
> extract method bodies from the meta data. All you get is method names
via
> #instance_methods and their arity. Does Smalltalk provide more?
yes.
I've quickly found this here, which expresses the relevant points:
The major difference I can see at the moment is that you seem to get
access to the method body in Smalltalk. That's nice. Though I have to
admit that I never missed this feature...
[but please let's close this subthread, as I move out of topic and out
of time.]
I think I get the difference now. Thanks.
Kind regards
robert
James Edward Gray II wrote:
George Moschovitis wrote:
There are nice diagrams of this relationship in Programming Ruby (Chapter 24: Objects and Classes).
Is this book available online?
The first edition of the book (now in its second edition) is available online, but the figures aren't in it. They are what you are after.
sad.
or you can just use ri:
ri Class
generates an ASCII version of the diagrams.where do i use it?
ri should be installed with Ruby. The documentation may or may not have been, depending on how you installed Ruby. If it is installed, typing "ri Class" at the command-line will fetch the document.
ok, it works.
I'll inline the document George mentioned below, for reference, but I don't personally feel it's as helpful as the figures in Programming Ruby.
[...]
he refered most possibly to this:
(this is what I would need as a UML diagramm)
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) |
^ |
> >
+----------------+
..
Robert Klemme wrote:
"Ilias Lazaridis" <ilias@lazaridis.com> schrieb im Newsbeitrag
news:d2rjbt$qs3$1@usenet.otenet.gr...[...]
The Ruby Object Model does not contain reflective MetaClasses, which
would enable to apply metadata even to methods.
[...]
if ruby _is_ fully reflective, than please provide the code for "class
definition recreation"http://lazaridis.com/case/lang/ruby.html#sayYourClassDefinition
[...]
[...]
#instance_methods and their arity. Does Smalltalk provide more?
yes.
I've quickly found this here, which expresses the relevant points:
The major difference I can see at the moment is that you seem to get
access to the method body in Smalltalk. That's nice. Though I have to
admit that I never missed this feature...
ok
[but please let's close this subthread, as I move out of topic and out
of time.]
I think I get the difference now. Thanks.
you are welcome.
Thank you for the conversation.
..
Never sad to support good authors in their craft so they can keep supplying us with excellent resources, in my opinion.
I do believe Programming Ruby is well worth the cover charge. It answers for me every question I've ever seen you ask here, and I'm willing to bet it took me less time to read than it did for you to compose all those emails. Just FYI.
James Edward Gray II
On Apr 4, 2005, at 10:05 AM, Ilias Lazaridis wrote:
James Edward Gray II wrote:
On Apr 4, 2005, at 9:04 AM, Ilias Lazaridis wrote:
Is this book available online?
The first edition of the book (now in its second edition) is available online, but the figures aren't in it. They are what you are after.
sad.
James Edward Gray II wrote:
James Edward Gray II wrote:
Is this book available online?
The first edition of the book (now in its second edition) is available online, but the figures aren't in it. They are what you are after.
sad.
Never sad to support good authors in their craft so they can keep supplying us with excellent resources, in my opinion.
please!
I reference only publicly available resources.
I would reference this book (it's online version), if it contained the figures [and intrested people could by the book of course].
No figures - no reference - no publicity (from my document).
sad.
btw: is the diagramm an UML one?
I do believe Programming Ruby is well worth the cover charge. It answers for me every question I've ever seen you ask here, and I'm willing to bet it took me less time to read than it did for you to compose all those emails. Just FYI.
I'm not intrested in books.
I'm intrested in providing an analysis / evaluation, which anyone can follow without cost (except internet access).
[btw: I'm not payed to do this]
James Edward Gray II
..
On Apr 4, 2005, at 10:05 AM, Ilias Lazaridis wrote:
On Apr 4, 2005, at 9:04 AM, Ilias Lazaridis wrote:
Ilias Lazaridis wrote:
I do believe Programming Ruby is well worth the cover charge. It answers for me every question I've ever seen you ask here, and I'm willing to bet it took me less time to read than it did for you to compose all those emails. Just FYI.
I'm not intrested in books.
I'm intrested in providing an analysis / evaluation, which anyone can follow without cost (except internet access).
The question is whether those evaluations will indeed be useful to the general public or more useful to yourself.
As far as I can see most of the content of it it is already available on the web through the Pickaxe 1 book and I think it is odd to turn that down just because you don't happen to get the figures with it.
And while I think it is nice that you are trying to understand this language I think you should start with the basics. You're already asking specific question about introspection when you have not yet understood the difference of "obj.method" in Ruby and in Python.
Please, start with the basics.
I know that that will take more time, but by this point you will likely agreed that Ruby *is* worth some time investment to learn it.
If you decide not to learn the basics then I think that your evaluations will not be worth much anyway.
Don't take this as an attack to you. I think this community is friendly and is not bothered by answering questions, but at some time it makes sense to examine the resources that are already available in public.
Thanks for your attention.
Florian Groß wrote:
[...] - (several comments)
Please, start with the basics.
[...]
Don't take this as an attack to you. I think this community is friendly and is not bothered by answering questions, but at some time it makes sense to examine the resources that are already available in public.
Read this thread carefully.
You will find several cases where community members run on surprises.
Thanks for your attention.
I've lost a little my process, as I found ruby intresting.
[Now, it's really time for me to close the thread, which has really an exceptional in-topic-ratio]
..