Andrew Wilson wrote:

It's the difference between this:

print;

and this:

print $_;

It is as far as I'm concerned exactly what topic is all about.
Exactly.


It let's you write subroutines that behave like builtins with respect
> to $_.  I think it's generally intended to be used like so:
sub my_print is given($default) {
  my @args = @_ // $default;
  ...
}

i.e. only doing stuff with $_ if no explicit parameters are passed.
I would expect that to be by far the most common use of C<is given>.


I don't think that'll be a massive problem with this.  It's not the same
thing at all because $_ is now lexical it's not passed to stuff you call
unless it specifically asks for it.  This will eliminate the trampling
over $_ several levels down.  Needlessly messing with caller's $_ will
become like not using strict or warnings.  Occasionally useful but
generally frowned on in a "don't do that" kind of way.
My sentiments precisely. Though it may only be frowned upon in a
"don't do that without documenting it" kind of way. ;-)

Damian

Reply via email to