On Mar 13, 2006, at 12:38 PM, Trans wrote:
> Rather then using a specific method for accessing the
> singleton/eigennclass, could we just use an alternate to dot-notation.
> I.e. Instead of 'x.eigenclass.foo' either 'x:foo' or 'x!foo', or
> somthing like that.

When I first encountered singleton class notation in Ruby:

   class <<obj; end

I thought of '<<' in this situation as a prefix operator on the object.
I suppose you hack the parser to understand that but I'm guessing it
would really tangle up the grammar.  In any case, the parser doesn't  
treat
the text after the 'class' keyword as an expression.  You can't  
substitute
'<<obj' for an expression that evaluates to an eigenclass.  I always  
thought
that was strange. Why doesn't the parser just look for an expression  
that
evaluates to a class object?  The superclass can be specified by an  
expression,
why can't the 'regular' class be handled in the same way?

In any case, I think that '<<obj' is seems out of place relative
to the rest of Ruby's syntax.

I'd prefer a method to access the singleton class object:

	obj.singleton_class

is OK but I tend to like more terse names:

	obj.sclass

If we had this, I would expect:

	class obj.sclass
	end

to do the obvious thing and open up obj's singleton class.

Gary Wright