--0016e647ead636f1af0496b758b7
Content-Type: text/plain; charset=ISO-8859-1

I think that, for this same reason, `using` should normally not apply
outside of the immediate lexical scope. I actually believed that this was
the default behavior, and explained why I thought it was a good idea on my
blog (http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-practice/).

In general, the most utility from refinements comes from being able to use
them freely, without worrying about accidentally breaking other code. In the
case of subclasses, for instance, I would want to be able to add a
refinement in a Rails 3.0.3 class (like ActionController::Base) for
convenience without worrying about breaking existing Rails apps that don't
expect core classes to suddenly change behavior.

I can understand the utility of offering the inherited style when desired,
but I don't think it should be the default. By default, the principle of
this feature requires that refinements modify zero code outside its lexical
scope.

Perhaps a special form of using that would also affect subclasses (for
example, for the case where Rails wants to expose ActiveSupport into its
subclasses):

class ActionController::Base
  using ActiveSupport, inherited: true
end

Yehuda Katz
Architect | Strobe
(ph) 718.877.1325


On Mon, Dec 6, 2010 at 12:12 AM, Shugo Maeda <shugo / ruby-lang.org> wrote:

> Hi,
>
> 2010/12/5 Yukihiro Matsumoto <matz / ruby-lang.org>:
> > I am neutral about local rebinding.  It is useful sometimes (as
> > someone has pointed out in this thread).  At the same time, I agree
> > with you that performance impact is a huge negative factor against
> > local rebinding.  We need more input.  Dave, what do you think?
> > Anyone else?
>
> I believe we should not support local rebinding.
>
> I guess local rebinding is not designed for refinements of classes
> which have many clients like built-in classes.  With local rebinding,
> when we refine a built-in class such as String, we have to take care
> carefully not to break existing code.  This means that, it's
> ridiculous to use the following refinement with local rebinding.
>
>  module MathN
>     refine Fixnum do
>      def /(other) quo(other) end
>    end
>  end
>
> My intention is to bring modularity into monkey patching, not to bring
> extensibility.  We already have enough extensibility in Ruby.
>
> --
> Shugo Maeda
>
>

--0016e647ead636f1af0496b758b7
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I think that, for this same reason, `using` should normally not apply outside of the immediate lexical scope. I actually believed that this was the default behavior, and explained why I thought it was a good idea on my blog (http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-practice/).<div>
<br></div><div>In general, the most utility from refinements comes from being able to use them freely, without worrying about accidentally breaking other code. In the case of subclasses, for instance, I would want to be able to add a refinement in a Rails 3.0.3 class (like ActionController::Base) for convenience without worrying about breaking existing Rails apps that don&#39;t expect core classes to suddenly change behavior.</div>
<div><br></div><div><div>I can understand the utility of offering the inherited style when desired, but I don&#39;t think it should be the default. Byefault, the principle of this feature requires that refinements modify zero code outside its lexical scope.</div>
<div><br></div><div>Perhaps a special form of using that would also affect subclasses (for example, for the case where Rails wants to expose ActiveSupport into its subclasses):</div><div><br></div><div>class ActionController::Base</div>
<div>  using ActiveSupport, inherited: true</div><div>end</div><div><br></div><div>Yehuda Katz<br>Architect | Strobe<br>(ph) 718.877.1325<br>
<br><br><div class="gmail_quote">On Mon, Dec 6, 2010 at 12:12 AM, Shugo Maeda <span dir="ltr">&lt;shugo / ruby-lang.org&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
2010/12/5 Yukihiro Matsumoto &lt;matz / ruby-lang.org&gt;:<br>
<div class="im">&gt; I am neutral about local rebinding.    &gt; someone has pointed out in this thread).   &gt; with you that performance impact is a huge negative factor against<br>
&gt; local rebinding.         뿼
&gt; Anyone else?<br>
<br>
</div>I believe we should not support local rebinding.<br>
<br>
I guess local rebinding is not designed for refinements of classes<br>
which have many clients like built-in classes.  笼
when we refine a built-in class such as String, we have to take care<br>
carefully not to break existing code.  
ridiculous to use the following refinement with local rebinding.<br>
<br>
  μ<div class="im">   
       
  
<br>
</div>My intention is to bring modularity into monkey patching, not to bring<br>
extensibility.     <br>
--<br>
<font color="#888888">Shugo Maeda<br>
<br>
</font></blockquote></div><br></div></div>

--0016e647ead636f1af0496b758b7--