On Sat, Dec 20, 2003 at 03:21:10PM -0800, Larry Wall wrote: : On Sat, Dec 20, 2003 at 03:12:53PM -0800, Jonathan Lang wrote: : : Why not do it the same way that namespace scoping collisions are resolved: : : the local scope trumps the caller's scope. Rinse, lather, repeat.
Actually, I didn't see that you said "caller's scope". That would imply some kind of dynamic scoping to multis, which I doubt we'll support except insofar as you can temporize a global name. : That's the default behavior--you ignore multi until you find the name : in a particular namespace, then you look to see if there are multis : within that namespace. I'm talking about what if you don't like the : default behavior where the collection is limited to the one namespace. : : Or to look at it another way, by default, the distance between : namespaces is infinitely large compared to the distance between : multimethods in a namespace. That might not always be what people : want. In particular, sometimes people might want the namespace : distance to be 0, and consider equally all multis of that name in any : (visible) namespace. It's a valid thing to want, but I just don't : think it should be the default. I should say, however, that the current lexical scope, the current package scope, and the *name global scope are all considered to be potentially the "current" namespace in just the same way as for a variable name. That is, any lexical declarations hide corresponding package or global declarations, and any package declarations hide corresponding global declarations. The question is what we mean by "corresponding". It may well be that for multis the definition of "corresponding" includes the signature, so that you could mix generic global multis with more specific package or lexical multis. The question I was trying to address was whether outer lexical multis should be hidden if there are any inner lexical mutlis of the same name, regardless of signature. Hmm. Now that I put it that way, it sounds as though the default should be to hide only the outer multis with the same signature, on the simple theory that a subroutine's complete name always includes its signature. You could always hide the outer ones with "is unique" (or however we do it). The fact that you might want to do this frequently is an argument for a shorthand such as my sub name! If we do it that way, people will want to have a way to say that the inner lexical scope supplies all of the multis of that name. Perhaps one can declare the name separately from the individual subs, as long as one didn't supply a signature: my sub name is unique {...}; my sub name (Foo $x) {...} my sub name (Bar $x) {...} my sub name ($x) is default {...} or my sub name! {...}; my sub name (Foo $x) {...} my sub name (Bar $x) {...} my sub name? ($x) {...} Hmm. Larry