On 10/2/05, Hal Fulton <hal9000 / hypermetrics.com> wrote:
> David A. Black wrote:
> >
> > I don't know what the term refers to in Python, but I do know that in
> > Ruby there's been a lot of terminological slippage over the years.
> > Some people use "metaclass" to refer to all singleton classes.  Others
> > use it to refer to the singleton classes of class objects.  Other have
> > argued that the only real metaclass in Ruby is the class Class (if you
> > define a metaclass as a class that produces classes).
>
> Well said. I would fall into the last camp.

I assumed this was coming from a Python perspective, as almost all of
the Google results were Python related (and the OP was trying to
subclass Class, where you subclass 'type' in Python to create a
metaclass).

I hate debating about terminology - I wish everything just had a firm
definition.  If we go by the definition you give for metaclass - a
class that produces a class (I like this definition) - Class is the
only metaclass in Ruby.

> > So the question of what "metaclasses" allow you to do depends a bit on
> > what you mean exactly, but I don't think there's much mystery or
> > reason for people not to try to understand them.
>
> Definitely agreed.

As far as I've been able to tell, they're not that complicated.  What
I fail to see is a situation where it gives you anything special,
especially given Ruby's openness with regard to class definitions.

The point of my reply was simply this: If you think you need to create
another metaclass in Ruby, chances are there's another (less painful)
way to get what you want.

itsme213 - do you have an example of a task for which you want to use
metaclasses?

--
Rob