--f46d04426cd022097e04ce7cd56e
Content-Type: text/plain; charset=UTF-8

Perhaps refinements should be scoped per-gem, rather than any arbitrary
"using" delimitation. Seems to me, that is generally the level at which we
care about them.

Would that simplify implementation and comprehensibility of usage to
something more manageable?


On Wed, Nov 14, 2012 at 1:35 PM, Aaron Patterson
<tenderlove / ruby-lang.org>wrote:

> On Wed, Nov 14, 2012 at 05:38:12AM +0900, headius (Charles Nutter) wrote:
>
> [snip]
>
> > And then there's this:
> >
> > class Foo < SomeParent
> >   def baz(str)
> >     ary.map {|name| str.camelize + name}
> >   end
> > end
> >
> > In this case, you have to check even more places for refinements to know
> what methods will be called:
> >
> > * Foo may have been previously refined. You must look for all reopenings
> of Foo to know what will be called.
> > * SomeParent or its parents may have been previously refined. You must
> look for all reopenings of SomeParent and its parents.
> > * The map method may force refinements on the block. you must look for
> all implementations of map() that might be called here to see if they force
> refinements into the block.
> >
> > This is supposed to be simpler?
>
> I have to agree.  It seems like this would be *much* more difficult to
> debug than if `camelize` is just monkey patched on to String.
>
> This code:
>
>   class Foo < SomeParent
>     def baz(str)
>       cached  tr.camelize
>       ary.map {|name| cached + name}
>     end
>   end
>
> Could have a completely different meaning than this code:
>
>   class Foo < SomeParent
>     def baz(str)
>       ary.map {|name| str.camelize + name}
>     end
>   end
>
> That seems extremely bad.
>
> --
> Aaron Patterson
> http://tenderlovemaking.com/
>
>


-- 
Sorry, says the barman, we don't serve neutrinos. A neutrino walks into a
bar.

Trans <transfire / gmail.com>
7r4n5.com      http://7r4n5.com

--f46d04426cd022097e04ce7cd56e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div>Perhaps refinements should be scoped per-gem, rather than any arbitrary &quot;using&quot;delimitation. Seems to me, that is generally the level at which we care about them.</div><div><br></div><div>Would that simplify implementation and comprehensibility of usage to something moremanageable?</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 14, 2012 at 1:35 PM, Aaron Patterson <span dir="ltr">&lt;<a href="mailto:tenderlove / ruby-lang.org" target="_blank">tenderlove / ruby-lang.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Nov 14, 2012 at 05:38:12AM +0900, headius (Charles Nutter) wrote:<br>
<br>
[snip]<br>
<br>
&gt; And then there&#39;s this:<br>
&gt;<br>
&gt; class Foo &lt; SomeParent<br>
&gt;  def baz(str)<br>
&gt;   ary.map {|name| str.camelize + name}<br>
&gt;  end<br>
&gt; end<br>
&gt;<br>
&gt; In this case, you have to check even more places for refinements to know what methods will be called:<br>
&gt;<br>
&gt; * Foo may have been previously refined. You must look for all reopenings of Foo to know what will be called.<br>
&gt; * SomeParent or its parents may have been previously refined. You mustook for all reopenings of SomeParent and its parents.<br>
&gt; * The map method may force refinements on the block. you must look forll implementations of map() that might be called here to see if they force refinements into the block.<br>
&gt;<br>
&gt; This is supposed to be simpler?<br>
<br>
I have to agree. It seems like this would be *much* more difficult to<br>
debug than if `camelize` is just monkey patched on to String.<br>
<br>
This code:<br>
<br>
 class Foo &lt; SomeParent<br>
  def baz(str)<br>
   cached = str.camelize<br>
   ary.map {|name| cached + name}<br>
  end<br>
 end<br>
<br>
Could have a completely different meaning than this code:<br>
<br>
 class Foo &lt; SomeParent<br>
  def baz(str)<br>
   ary.map {|name| str.camelize + name}<br>
  end<br>
 end<br>
<br>
That seems extremely bad.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Aaron Patterson<br>
<a href="http://tenderlovemaking.com/" target="_blank">http://tenderlovemaking.com/</a><br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Sorry, says the barman, we don&#39;t serve neutrinos. A neutrino walks into a bar.<br><br>Trans &lt;<a href="mailto:transfire / gmail.com" target="_blank">transfire / gmail.com</a>&gt;<br>
<a href="http://7r4n5.com" target="_blank">7r4n5.com</a>   <a href="http://7r4n5.com" target="_blank">http://7r4n5.com</a><br><br><br><br>
</div>

--f46d04426cd022097e04ce7cd56e--