Hi,

2010/11/25 Shugo Maeda <shugo / ruby-lang.org>:
> How about to separate them into the following three patches?
>
> =A01. changes of control frames and method lookup
> =A02. Refinements support
> =A03. nested methods support

Seems good.


> I forgot to mention that refinements are enabled in class or module
> definitions where Module#refine is called.
>
> =A0class Foo
> =A0 =A0refine Fixnum do
> =A0 =A0 =A0def /(other) quo(other) end
> =A0 =A0end
>
> =A0 =A0p 1 / 2 =A0#=3D> (1/2)
> =A0end

Aha!

> Do we need Kernel#refine?

I want it.


>> I guess that this `using_refine' is useful itself (though its
>> name is arguable). =A0In addition, it allows us to write
>> MyXmlFormat as follows:
>>
>> =A0module MyXmlFormat
>> =A0 =A0using_refine(Integer) do
>> =A0 =A0 =A0def to_xml; ...; end
>> =A0 =A0end
>>
>> =A0 =A0using_refine(String) do
>> =A0 =A0 =A0def to_xml; ...; end
>> =A0 =A0end
>>
>> =A0 =A0using_refine(Hash) do
>> =A0 =A0 =A0def to_xml; ...; end
>> =A0 =A0end
>> =A0end
>
> I guess Module#refine works the same as using_refine in this case.

Hmm.  Then, when no block is given to Module#refine, how about
adding an implicit block that includes the outer module?

  module FooExt
    refine(Foo)
    ...
  end

(equivalent to)

  module FooExt
    refine(Foo) { include FooExt }
    ...
  end


> 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.  But conventionally, essential features that involve
code block (such as class/module definition, method definition
and control statements) have their special keywords.


> I guess it's unlikely that you need refine module functions in
> real-world applications.

I thought that one of motivating examples of this feature is
mathn.rb.  In fact, mathn.rb changes Math module to complex-
aware one.

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