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 ).
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
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 ).
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?
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:
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 ).
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.
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,
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:
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.)
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.
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:
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.
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.
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