Hi --

On Wed, 15 Mar 2006, Gary Wright wrote:

>
> On Mar 14, 2006, at 10:44 AM, dblack / wobblini.net wrote:
>> I'm certainly a Kernel#s[ingleton_]class advocate, but I don't think
>> it's obvious that this change in the behavior of the class keyword
>> would follow, since:
>>
>>   class some_class_in_a_variable
>> 
>> doesn't work.  I don't know the reasoning behind it.
>
> Yes.  My comment regarding expressions after the 'class' keyword
> was a more general comment on the syntax/semantics of a class/end block
> than anything specific to singleton class notation.
>
> I just find the semantics/syntax of the 'class' keyword a bit strange.
>
> Here is another example:
>
> 	(class A; self; end)
>
> is not a valid expression in a method definition but:
>
> 	(class << obj; self; end)
>
> is just fine.

Either is fine:

irb(main):001:0> def x; class << String; self; end; end
=> nil
irb(main):002:0> x
=> #<Class:String>


> 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
>
> would be analogous to
>
> 	expression.class_eval { # code }

Do you mean you'd like the class keyword not to start a new local
scope?


David

-- 
David A. Black (dblack / wobblini.net)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

"Ruby for Rails" chapters now available
from Manning Early Access Program! http://www.manning.com/books/black