>>>>> "Chaim" == Chaim Frenkel <[EMAIL PROTECTED]> writes:

>>>>> "TC" == Tom Christiansen <[EMAIL PROTECTED]> writes:
>>> grep { $_ == 1 } 1..1_000_000
>>> grep doesn't short-circuit.

TC> I never did figure out why "last" {w,sh,c}ouldn't be made to do
TC> that very thing.

Chaim> Hey, I suggested that a while ago, but Randal shot it down.

Chaim> Something about the block not being a loop, I think.

I think it was more along the lines that Damian (I think) enumerated
of "what value does a block being evaluated for a value but exited
with 'last' return?".  As in, how do you indicate with 'last' that you
want a false return, or a true return?  This never comes up with a do
{} block, or a subroutine block, because while those are being
evaluated for a value, they don't respect last/next/redo.  Your
request to have the grep block understand 'last' was the first block
in Perl history that would have simultaneously needed to exit early
*with* a value.  And we hadn't come around that block yet. :)

We really need a clean way to distinguish those four cases:

    "yes" and keep going
    "no" and keep going
    "yes" and abort after this one
    "no" and abort after this one

What would you have "last" do?  And how would you distinguish "the
other one"?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to