Metaobjects in Ruby

I’m working on a paper for a class on Meta Programming Languages,
Systems, and Architectures, and one of the possible projects is to
compare meta programming facilities (e.g. reflection, introspection,
intercession, et. al.) between Ruby and Smalltalk (I do admit that
there was a bit of ahem influence in the selection of projects :wink: ).
Now to start I was wondering if Ruby uses Metaobjects. If yes, where
is a good point to start gathering information on it? If not, which
are the facilities that Ruby uses to achieve reflection,
introspection, etc.? And again, where can I get more information on
it?

Needless to say I’ll make the paper available to the Ruby repository
upon finishing. Cheers
-C

http://www.ruby-doc.org/docs/ProgrammingRuby/html/ospace.html
http://www.ruby-doc.org/docs/ProgrammingRuby/html/classes.html

It probably does not exhaustively describe all of Ruby's features for
introspection and meta-classes etc.

Regards,

  Michael

···

On Sat, May 29, 2004 at 11:26:31AM +0900, Claus Spitzer wrote:

I'm working on a paper for a class on Meta Programming Languages,
Systems, and Architectures, and one of the possible projects is to
compare meta programming facilities (e.g. reflection, introspection,
intercession, et. al.) between Ruby and Smalltalk (I do admit that
there was a bit of *ahem* influence in the selection of projects :wink: ).
Now to start I was wondering if Ruby uses Metaobjects. If yes, where
is a good point to start gathering information on it? If not, which
are the facilities that Ruby uses to achieve reflection,
introspection, etc.? And again, where can I get more information on
it?

“Claus Spitzer” DocBoobenstein@gmail.com wrote in message
news:a7c2a81904052819266b9104b6@mail.gmail.com
[snip]

Now to start I was wondering if Ruby uses Metaobjects. If yes, where
is a good point to start gathering information on it? If not, which
are the facilities that Ruby uses to achieve reflection,
introspection, etc.? And again, where can I get more information on
it?
[snip]

Well, there’s a chapter on Ruby “metaclass hackery” here:

http://www.visibleworkings.com/little-ruby/Chapter3.pdf

Sadly, the book was left unfinished …

HTH
Sean

Hi –

Claus Spitzer DocBoobenstein@gmail.com writes:

I’m working on a paper for a class on Meta Programming Languages,
Systems, and Architectures, and one of the possible projects is to
compare meta programming facilities (e.g. reflection, introspection,
intercession, et. al.) between Ruby and Smalltalk (I do admit that
there was a bit of ahem influence in the selection of projects :wink: ).
Now to start I was wondering if Ruby uses Metaobjects. If yes, where
is a good point to start gathering information on it? If not, which
are the facilities that Ruby uses to achieve reflection,
introspection, etc.? And again, where can I get more information on
it?

I would look at the pickaxe book’s chapter on reflection
(http://www.rubycentral.com/book/ospace.html), which covers a lot of
topics you’ll probably find relevant and interesting, including
runtime callbacks, examining ObjectSpace, and several others.

David

···


David A. Black
dblack@wobblini.net

what is intercession ?

···

il Sat, 29 May 2004 11:26:31 +0900, Claus Spitzer DocBoobenstein@gmail.com ha scritto::

I’m working on a paper for a class on Meta Programming Languages,
Systems, and Architectures, and one of the possible projects is to
compare meta programming facilities (e.g. reflection, introspection,
intercession,

Hi –

“Sean Ross” sross@connectmail.carleton.ca writes:

“Claus Spitzer” DocBoobenstein@gmail.com wrote in message
news:a7c2a81904052819266b9104b6@mail.gmail.com
[snip]

Now to start I was wondering if Ruby uses Metaobjects. If yes, where
is a good point to start gathering information on it? If not, which
are the facilities that Ruby uses to achieve reflection,
introspection, etc.? And again, where can I get more information on
it?
[snip]

Well, there’s a chapter on Ruby “metaclass hackery” here:

http://www.visibleworkings.com/little-ruby/Chapter3.pdf

I know this sounds weird, but I don’t think metaclasses are part of
metaprogramming or reflection. I think “metaclass”, as used in the
pickaxe, is just a term for the singleton class of a Class object. (I
also seem to remember some sentiment on the part of Guy Decoux and
possibly others that the term isn’t really necessary at all, but I
never got that discussion entirely straight.)

David

···


David A. Black
dblack@wobblini.net

I would look at the pickaxe book’s chapter on reflection
(http://www.rubycentral.com/book/ospace.html), which covers a lot of
topics you’ll probably find relevant and interesting, including
runtime callbacks, examining ObjectSpace, and several others.

Hal Fulton also does a marvelous job of describing reflection and
run-time extension in chapter 5 “OOP and Dynamicity in Ruby” of his
“The Ruby Way” book. It’s longer and a bit more advanced. I learned a
ton from it.

···


David Heinemeier Hansson,
http://www.instiki.org/ – A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/ – Web-based Project Management
http://www.loudthinking.com/ – Broadcasting Brain
http://www.nextangle.com/ – Development & Consulting Services

David Alan Black wrote:

Hi –

“Sean Ross” sross@connectmail.carleton.ca writes:

“Claus Spitzer” DocBoobenstein@gmail.com wrote in message
news:a7c2a81904052819266b9104b6@mail.gmail.com
[snip]

Now to start I was wondering if Ruby uses Metaobjects. If yes, where
is a good point to start gathering information on it? If not, which
are the facilities that Ruby uses to achieve reflection,
introspection, etc.? And again, where can I get more information on
it?

[snip]

Well, there’s a chapter on Ruby “metaclass hackery” here:

http://www.visibleworkings.com/little-ruby/Chapter3.pdf

I know this sounds weird, but I don’t think metaclasses are part of
metaprogramming or reflection. I think “metaclass”, as used in the
pickaxe, is just a term for the singleton class of a Class object. (I
also seem to remember some sentiment on the part of Guy Decoux and
possibly others that the term isn’t really necessary at all, but I
never got that discussion entirely straight.

Well, the original post asked about meta Objects in Ruby so
it seem natural that meta classes were mentioned in the thread
(the provided link is does a pretty good job in explaining Ruby’s
meta class system IMO). Besides, a good understanding of Ruby’s
meta class system is certainly helpful (and probably necessary if you
want to understand what you are doing) for meta programming
anyway - irrespective of whether meta (singleton classes of) classes
are part of Ruby meta programming or not.

/Christoph

Thanks to everyone that responded. I’ll be digging into the documents
further down the week, but what I’ve seen at a glance seems to hit the
spot. I cannot find enough words to describe how grateful I am.

As for the person who asked what intercession is, let me blatantly
steal the definition from someone else’s slides (
http://www.cs.tut.fi/~kk/webstuff/SmalltalkKalvot.pdf ):

  • Introspection is the ability of a program to observe and therefore
    reason about its own state.
  • Intercession is the ability of a program to modify its own
    execution state or alter its own interpretation or meaning. Ability to
    add new behavior to program as it is executing.

The above are by no means complete, nor are they mutually exclusive…
there is a fuzzy boder.
-C