On Fri, 20 Sep 2002, Larry Wall wrote:
> The current thinking as of Zurich is that the "given" passes in
> separate from the ordinary parameters:
>
>     sub ($a,$b,$c) is given($x) {...}
>
> That binds the dynamically surrounding $_ to $x as an out-of-band
> parameter.  Can also bind to $_ to make it the current topic.

Does this mean that we allow/encourage uses of $_ other than as a default
for an optional argument?  I think it would be less confusing and
error-prone to associate the underscore-aliasing with the parameter $_
will be replacing, i.e. this

        sub foo($a, $b = given) { ... }

vs this

        sub foo($a; $b) is given($b) { ... }

or this

        sub foo($a; $b) is given($c) {
                $b //= $c;
                ...
        }

Furthermore, if the caller can pass undef for the second parameter, I
don't see a way to distinguish in the third variant between a legitimately
passed undef, for which we don't want $_, and a missing optional argument,
for which we do.

/s


Reply via email to