From: Charles Oliver Nutter Date: 2009-02-26T06:07:16+09:00 Subject: [ruby-core:22502] Re: YASNP (Yet Another Selector Namespace Proposal) 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. > (2) With a particular namespace in scope, will there be a way to > explicitly invoke a conflicting method from a different namespace (i.e. > Assume that namespaces X and Y both define a method "to_xml" on Object. > Will there be a way to explicitly invoke the Y version of "to_xml" from > code that is currently in the scope of the X namespace.) Probably not. This would probably be a rare case, but it would be a strong argument for making namespaces more fine-grained. Of course, Dan Berger's proposal of a per-call syntax would resolve this, but it's more verbose. - Charlie