All pastes #2061902 Raw Edit

Mine

public text v1 · immutable
#2061902 ·published 2011-05-17 02:30 UTC
rendered paste body
To: Perl5 Porters Mailing List <perl5-porters@perl.org>
Subject: more given prevarications
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
X-Mailer: nmh v1.3 && nvi v1.79 (duh!)
X-Palindrome: Mr. Owl ate my metal worm.
Date: Mon, 16 May 2011 18:34:05 -0600
From: Tom Christiansen <tchrist@perl.com>

perlsyn lies when it says:

    C<when> executes the statement I<when> C<$_> smart matches C<EXPR>, and
    then either C<break>s out if it's enclosed in a C<given> scope or skips
    to the C<next> element when it lies directly inside a C<for> loop.

That's not true.  This works perfectly well:

    use 5.010;

    @names = qw(Peter Bob Jim David Stark);

    for (@names) {
        func();

    }

    sub func { 
        say "$_ is Alice or Bob"  when [ qw/Alice Bob/ ];
        say "$_ is Chris, David, or Ellen" when [ qw/Chris David Ellen/ ];
        default { say "Who is $_?" }
    }

It at some later point suggests:

    This doesn't work if you explicitly specify a loop variable,
    as in C<for $item (@array)>. You have to use the default
    variable C<$_>. (You can use C<for my $_ (@array)>.)

Well *DUH* if you're foolish enough to use a stupid lexical $_, 
then of course stuff doesn't work!  Don't do that.  The correct
construct is the one I use above, not the dumb one that's 
misrecommended.

Later it reads:

    when($foo)

        is exactly equivalent to

    when($_ ~~ $foo)

And then it goes on to list a whole bunch of exclusions.

Therefore, it is lying.  It is *NOT* exactly equivalent to that.
We should be so lucky.  

And its list of exclusions is not definitive.  There is no
way to figure out what the bloody thing does without testing it
yourself.  The documentation is misleading and wrong, unhelpful
and ambiguous.

It should be removed.

And it's been what, almost four years that people have put up
with this?

Unbelievable.

--tom