develooper Front page | perl.perl5.porters | Postings from August 2012

Re: fixing smartmatch just hard enough (and when, too)

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
August 19, 2012 12:16
Subject:
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
A9FD92BA-CE60-447C-9F5C-A3F0A623BC74@cpan.org
rjbs wrote:
> Also, `when` should be valid inside an auto-topicalizing `while`, providing an
> implicit next, making its behavior more generic so that `when` can be used
> safely everywhere that it makes sense.

Please keep

    while(<>)

and

    while(defined($_ = <>))

equivalent.

Otherwise while<> would have to be deparsed as while<>, removing a useful feature of Deparse (finding out how perl is interpreting the while).

What do you want to do about this?

$ perl -E 'given(1) { for my $x (2) { break } } warn ok'
ok at -e line 1.
$ perl -E 'given(1) { for (2) { break } }'
Can't "break" in a loop topicalizer at -e line 1.

I think the best solution is to make when (and default) always do an implicit next.  Also make given respond to next and last, just like a bare block.  Deprecate break, but make it consistently exit the innermost given, without complaining about intervening frames.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About