Hi,

2010/11/26 Shugo Maeda <shugo / ruby-lang.org>:
>>> I guess Module#refine works the same as using_refine in this case.
>>
>> Hmm. =A0Then, when no block is given to Module#refine, how about
>> adding an implicit block that includes the outer module?
>>
>> =A0module FooExt
>> =A0 =A0refine(Foo)
>> =A0 =A0...
>> =A0end
>>
>> (equivalent to)
>>
>> =A0module FooExt
>> =A0 =A0refine(Foo) { include FooExt }
>> =A0 =A0...
>> =A0end
>
> Could you tell me why you need this feature?

Because it requires less indentation, I thought.
But I found out that it has a problem of [ruby-core:33386] (1)...


>>> I don't think we need new keywords even if it is a big change,
>>> because some essential features such as module inclusion
>>> have no keyword in Ruby.
>>
>> Indeed. =A0But conventionally, essential features that involve
>> code block (such as class/module definition, method definition
>> and control statements) have their special keywords.
>
> I guess that most of these constructs have reasons why they need
> keywords and special syntax.

I don't think so.  "class Foo; end" can be written as "Foo =3D
Class.new { }" (though there are indeed subtle differences between
them).


> If refine is a keyword, there is one good thing. =A0We don't need "do"
> after class names.
>
> =A0refine Fixnum
> =A0 =A0...
> =A0end

The API design that "def" statements are put in a Ruby's block,
is slightly weird (for me).  I guess that there is no precedent of
such a style in Ruby's embedded featues, except meta programming
(such as Class.new and class_eval).
From now on, does Ruby encourage such a style in casual use?

--=20
Yusuke Endoh <mame / tsg.ne.jp>