Quoting Gary Wright <[EMAIL PROTECTED]>:
> And as I said earlier, Ruby is quite happy to have an expression
> as the superclass such as:
>
> class ProxyArray < DelgateClass(Array)
> end
>
> I would think that
>
> class expression
> #code
> end
>
> [should] be analogous to
>
> expression.class_eval { # code }
The above example illustrates exactly why general expressions aren't
allowed as the "operand" for the class keyword. There'd be an
ambiguity around:
class SomeConstant < some_expression
end
...is SomeConstant the name of a new class to define, and the result
of some_expression its superclass?
...or is SomeConstant an object on which to call #<, and the result
of some_expression the argument to the call?
You can't simultanously have a special syntax for class declaration,
and still allow general expressions, without writing a really
tortured grammar and deeply confusing people in the process.
matz wisely opted to stick with just one -- the former -- which is
the standard notation for class declarations we use every day.
-mental
_______________________________________________
Rubygrammar-grammarians mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygrammar-grammarians