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

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

Thread Previous | Thread Next
Father Chrysostomos
August 19, 2012 12:16
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
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(defined($_ = <>))


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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About