[EVALUATION] - E03 - jamLang Evaluation Case Applied to Ruby

C

Csaba Henk

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
you will want. Why? Because you refer to a method via the object to which
it belongs, and this always give you a fresh objectification of the
method, as we have discussed.

But. If you stick to refer to methods via their carrier objects (which
you seem to do, and which seems to make sense), then why can't you just
use the object itself as the basic reference point, without further
considerations? Why would be talker.meta[:sayYourName] worse (in any
sense) than what the (disfunctional) talker.method:)sayYourName) could
be?

I mean, the certain object gives the namespace via which you can access
the method as an object. Then why not use the same namespace for storing
the metainformation of the method (without any bitterness)?

Even better, you could make the class or module carry the
metainformation, to which the method belongs as an instance method (each
method is registered as an instance method of some class or module --
singleton methods of an object are instance methods of the metaclass of
the object [accessible as in

class << "a"; self; end

and it is a permanent object, unlike methods]).

This has the advantage that method objects then determine their proposed
metainformation, as they hold a reference to the class/module to which
they belong as an instance method. Alas, in present ruby you can't get
this information explicitly, and now if you say it's a flaw in Ruby, I'd
say I agree (although one which doesn't seem to cause great problems).

For example,

[1].method:)at).inspect

gives the string "#<Method: Array#at>", but there is no method of the
method object [1].method:)at) which would give you Array, the class. In
this particular case, as a clumsy workaround, you could parse out Array
from the above string, but this won't work if the method in question
belongs to an anonymous class (like objects' metaclasses).

Huh, I hope it's not too messy.

Csaba
 
I

Ilias Lazaridis

Robert said:
news:[email protected]... [...]
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).]
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.

..
 
R

Robert Klemme

Ilias Lazaridis said:
Robert said:
news:[email protected]... [...]
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, 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
 
I

Ilias Lazaridis

[...]
[...]
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.]

..
 
J

James Edward Gray II

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.
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'.

+------------------+
| |
Object---->(Object) |
^ ^ ^ ^ |
| | | | |
| | +-----+ +---------+ |
| | | | |
| +-----------+ | |
| | | | |
+------+ | Module--->(Module) |
| | ^ ^ |
OtherClass-->(OtherClass) | | |
| | |
Class---->(Class) |
^ |
| |
+----------------+

------------------------------------------------------------------------

Class methods:
new

Instance methods:
allocate, inherited, initialize_copy, new, superclass
 
I

Ilias Lazaridis

Csaba said:
You can find something like this at
http://www.ruby-doc.org/core/classes/Class.html -- 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.

..
 
R

Robert Klemme

Ilias Lazaridis said:
[...]
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

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
 
I

Ilias Lazaridis

Robert said:
Ilias Lazaridis said:
[...]
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
[...]

[...]
yes.

I've quickly found this here, which expresses the relevant points:

http://www.zenspider.com/Languages/Smalltalk/VsJava.html

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.

..
 
I

Ilias Lazaridis

James said:
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.


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

..
 
I

Ilias Lazaridis

Csaba said:
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.

..
 
J

James Edward Gray II


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
 
I

Ilias Lazaridis

James said:
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

..
 
F

Florian Groß

Ilias said:
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.
 
I

Ilias Lazaridis

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]

..
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top