Larry Wall wrote:
> Larry Wall wrote:
> : 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.
OK. When I said the above, I was thinking of how Apocalypse 6 makes
mention of a C<CALLER::> prefix in order to provide access to the caller's
scope, and I was assuming that this was a generalized dynamic scoping
feature.
Conceptually, I like the parallel between lexical scopes and class
namespaces; in many ways, C<CALLER::> seems to be to routines what
C<SUPER::> would be to classes.
> 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.
More to the point, if two routines have the same signature, you aren't
going to be able to use argument types to distinguish between them.
> 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.
If I'm following you, the first line of each sample above would mean that
the dispatching done for C<name> would never look outside of the current
scope, right? And a routine that has a signature but C<is unique> cannot
be seen from the lexical scopes of any called routines (for the purpose of
dispatching), right?
So could C<name> be seen by a called routine? I know that you're blinding
it from looking up to its caller; but could other routines look up to it?
=====
Jonathan "Dataweaver" Lang
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/