On Fri, 2002-09-20 at 10:36, Larry Wall wrote:
> On Thu, 19 Sep 2002, Brent Dax wrote:
> : (An aside: it strikes me that you could use C<given> as a scoped lexical
> : alias, i.e.
> : given $bar -> $foo {
> : print $foo;
> : }
> Sure, though it also aliases to $_.
>
Does that mean that I can't
for $x -> $_ {
for $y -> $z {
print "$_, $z\n";
}
}
And expect to get different values?
> : # signatureless sub: A sub that does not specify a prototype,
> : # and thus has a default prototype of:
> : #
> : # sub($_//=$_){};
> : #
> : # ne?
> :
> : More like:
> :
> : a sub that was created with the arrow (->) or a bare block and
> : does not specify a prototype, and thus has a default prototype
> : of:
> :
> : -> ($_ //= $OUTER::_) { };
>
> OUTER only works for lexical scopes. What you want is out-of-band access
> to the $_ in the surrounding dynamic context
>
I assumed that's what C<//=$_> was. It does have the disadvantage of
looking like variable assignment, though.
> The current thinking as of Zurich is that the "given" passes in
> separate from the ordinary parameters:
>
> sub ($a,$b,$c) is given($x) {...}
>
Ok, that seems saner.
> That binds the dynamically surrounding $_ to $x as an out-of-band
> parameter. Can also bind to $_ to make it the current topic.
>
> Not sure of the syntax for pointy subs yet. Maybe
>
> -> ($a,$b,$c) is given($x) {...}
I was with you up until this last example. Can you give a surrounding
context so I can see how that would be used?
--
Aaron Sherman <[EMAIL PROTECTED]>