From: Yehuda Katz Date: 2009-02-26T06:12:19+09:00 Subject: [ruby-core:22507] Re: YASNP (Yet Another Selector Namespace Proposal) --000e0cd2287cc3eb500463c4b3e9 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I think it's likely the case that explicit calls to namespaced methods should be allowed: X.Y:to_xml X.send_with_namespace(Y, :to_xml) Something like ^^? -- Yehuda 2009/2/25 Charles Oliver Nutter > 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 > > > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --000e0cd2287cc3eb500463c4b3e9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I think it's likely the case that explicit calls to namespaced methods = should be allowed:

X.Y:to_xml
X.send_with_namespace(Y, :to_xml)
Something like ^^?

-- Yehuda

2009/2/25 Charles Oliver Nutter <charles.nutter@sun.com>
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? =A0(i.e. Assume that namespac= es X and Y both defined a method "to_xml" on Object, and that bot= h are in scope. =A0Which version will be invoked?)

In my prototype they're first-come, first-served. You can have many nam= espaces 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 =3D> String
using Bar =3D> String
puts 'hello'.to_s # =3D> 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 n= amespaces X and Y both define a method "to_xml" on Object. =A0Wil= l there be a way to explicitly invoke the Y version of "to_xml" f= rom 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 verb= ose.

- Charlie





--
Yehuda Katz
Develope= r | Engine Yard
(ph) 718.877.1325
--000e0cd2287cc3eb500463c4b3e9--