From: Charles Oliver Nutter Date: 2009-02-27T03:23:37+09:00 Subject: [ruby-core:22550] Re: YASNP (Yet Another Selector Namespace Proposal) 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". >> 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. > > Why not start from Dan's proposal and then figure out how to make a > magic syntax that reduces the verbosity? I'm all ears :) - Charlie