From: Yehuda Katz Date: 2009-02-19T15:22:59+09:00 Subject: [ruby-core:22246] YASNP (Yet Another Selector Namespace Proposal) --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. Exa= mple:

# merb/core_ext/string.rb

namespace Merb
  class String
   &= nbsp;def to_s
      super + "Awesome"
  = ;  end
  end
end

# merb/application.rb

use Merb::String

class Foo
  def bar(str)
    str.to_s
&n= bsp; end
end

Some more examples are= at: https://= gist.github.com/83d390aea81a12f1667c

The basic implementation idea is that there be a new no= de 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 t= he selector AND the namespaces. So it shouldn't be a huge performance h= it.

Thoughts?

--
Yehuda Katz
Developer= | Engine Yard
(ph) 718.877.1325
--000e0cd32d0438735504633f92d1--