On Sat, Dec 22, 2007 at 11:50:41PM +0900, Charles Oliver Nutter wrote:
> The complication is that under normal circumstances a method has no 
> knowledge of whether it's being called inside a namespace or not, since 
> the installation of the namespace itself is just another method call. So 
> every method in the system would have to check whether they are being 
> called under a namespace.

The technique I used in:

  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/161439

was to modify caller's frame to signify that a particular namespace is
active.

If use and namespace were keywords rather than method calls, they could
do this without the use of caller_binding. :)

This technique is slow, but iirc only for methods defined in a
namespace (but the cost is paid regardless whether the namespace is
active).

If namespaces were lexical elements, I think the performance penalty
could be minimized, as it would be known at compile time which method
lookup tables to use for a given call.

Paul