From: Michal Suchanek Date: 2009-02-27T02:07:04+09:00 Subject: [ruby-core:22547] Re: YASNP (Yet Another Selector Namespace Proposal) 2009/2/26 Gary Wright : > > On Feb 26, 2009, at 1:30 AM, Charles Oliver Nutter wrote: > >> Jim Weirich wrote: >>> >>> Methods invoking super need to be designed to work together (at least to >>> some degree[3]). ��Namespaces are for keeping unrelated methods from >>> colliding. ��Having super search namespaces from the original call site will >>> mix unrelated methods. >> >> I've talked about this a bit with Yehuda offline and super is definitely a >> peculiar case. I agree with your assertions, and there's another reason why: >> super from within that module has no real hierarchy to climb. In a typical >> "include MyModule" case, the module is enlisted in the actual class >> hierarchy, so it can run its code and "super up" the included hierarchy >> correctly. In the namespaced case, since we're only modifying what happens >> at the call side, MyModule is totally disconnected from the hierarchy >> attached to self's class. There's no going back. > > I'm still trying to work out the ramifications of Yehuda's proposal. ��Some > more thoughts: > > Yehuda uses 'super' in a namespaced method in his first example at: > . ��If super in this > case does not resume searching through namespaces that were in scope at the > original call site but instead uses those active at the super call site, > does the singleton class get searched again? ��If so then it will be searched > *twice*, once via the lookup sequence at the original call site (because > singleton classes take precedence over namespace modules) and then *again* > when super gets called. If not, it implies some more state has to hang > around to control super's lookup chain. > > Since singleton classes get searched before namespaces, will a 'super' in a > singleton method resume the search and find namespaced versions of the > method or not? ��Seems like more lookup state to manage. > > What about method_missing? It is common for method_missing to intercept some > messages but punt to ancestors by calling super for others. > > Should method_missing be prohibited in a namespace module? ��Or perhaps the > method_missing logic should skip namespace modules? ��If method_missing is > found in a namespace module and super is called, what happens? > For me it looks like selector namespaces get us some of the problems of multiple inheritance, at least when super is concerned. Clearly you might want super to search the namespaces in which your method was defined (or not in some cases) but also the namespaces in which the method was called - as with method_missing. Perhaps some qualifiers would come handy here as was proposed for calling a single method in a different namespace. Thanks Michal