From: Gary Wright Date: 2009-02-27T04:01:55+09:00 Subject: [ruby-core:22555] Re: YASNP (Yet Another Selector Namespace Proposal) On Feb 26, 2009, at 1:23 PM, Charles Oliver Nutter wrote: > Austin Ziegler wrote: >> On Wed, Feb 25, 2009 at 4:07 PM, Charles Oliver Nutter >> wrote: >>> Jim Weirich wrote: >>>> (1) If two selector namespaces are in scope, and they both define >>>> a method >>>> of the same name, which one takes precedence? (i.e. Assume that >>>> namespaces >>>> X and Y both defined a method "to_xml" on Object, and that both >>>> are in >>>> scope. Which version will be invoked?) >>> In my prototype they're first-come, first-served. You can have many >>> namespaces affect the same class and provide the same methods, and >>> they're >>> searched in "using" order: >>> >>> module Foo; def to_s; 'here'; end; end >>> module Bar; def to_s; 'there'; end; end >>> using Foo => String >>> using Bar => String >>> puts 'hello'.to_s # => outputs "here" >>> >>> It seems like the most straight-forward behavior to me. >> Why not LIFO? > > My brain works FIFO I guess. I read this as "check Foo first, then > check Bar". I find the FIFO ordering strange since it seems to go against the normal grain of nested lexical scopes as well as the search order of included modules. The proposed 'using' keyword creates a lexical scope that extends to the end of the file. It is strange that a subsequent 'using' keyword doesn't create a nested scope within the first. With a FIFO interpretation it implies that that the nesting is reversed. Very un-ruby-like to me. Gary Wright