Yehuda Katz wrote: > 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. Here's a hacked-together implementation for JRuby: http://pastie.org/393746 The idea is that at parse time it saves off the node associated with whatever you're "use"ing and attaches it to future parsed calls. Then there's a modification to calls to use that namespace first if it's present. Caveats: * HACKHACKHACK * Only works for single-arg "call" in this case, but easy to generalize to all other calls * The namespace never gets turned off in this example. It wouldn't be hard to add with parser help, but there's no trigger I can use in this simple version. * Interpreter-only. Compilation would be a bit trickier, but not much. If I were going to implement this for real I'd probably have a special "namespaced call site" that does the magic for all calls. A fortunate side effect of this impl is that the "to_s" inside the namespaced Merb::String actually goes to the real String, since "self" is the 'crazy time' object below. This may or may not be desirable, but it was easier than trying to make super work. - Charlie