--000e0cd32d0438735504633f92d1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
The idea is to make selectors like optional versions of Python imports.
Example:
# merb/core_ext/string.rb
namespace Merb
class String
def to_s
super + "Awesome"
end
end
end
# merb/application.rb
use Merb::String
class Foo
def bar(str)
str.to_s
end
end
Some more examples are at: https://gist.github.com/83d390aea81a12f1667c
The basic implementation idea is that there be a new node named
call_with_namespace that would hold any namespaces registered for the file
in question. This would be a parse-time transform (based on a new use
keyword). You would also be able to cache the method lookup, based on the
selector AND the namespaces. So it shouldn't be a huge performance hit.
Thoughts?
--
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325
--000e0cd32d0438735504633f92d1
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
The idea is to make selectors like optional versions of Python imports. Example:<div><br></div><div># merb/core_ext/string.rb</div><div><br></div><div>namespace Merb</div><div> class String</div><div> def to_s</div><div>
super + "Awesome"</div><div> end</div><div> end</div><div>end<br clear="all"><br></div><div># merb/application.rb</div><div><br></div><div>use Merb::String</div><div><br></div><div>class Foo</div><div>
def bar(str)</div><div> str.to_s</div><div> end</div><div>end</div><div><br></div><div>Some more examples aret: https://gist.github.com/83d390aea81a12f1667c</div>
<div><br></div><div>The basic implementation idea is that there be a new node named call_with_namespace that would hold any namespaces registered for the file in question. This would be a parse-time transform (based on a new use keyword). You would also be able to cache the method lookup, based on the selector AND the namespaces. So it shouldn't be a huge performance hit.</div>
<div><br></div><div>Thoughts?</div><div><br>-- <br>Yehuda Katz<br>Developerngine Yard<br>(ph) 718.877.1325<br>
</div>
--000e0cd32d0438735504633f92d1--