Randal L. Schwartz wrote:
> 
> 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"?

This is my suggestion: the only effect of "last" should be to signal
to the grep not to iterate further; and, as with the current sitch,
whatever the last evaluated value in the block would be the "returned"
value.  So to effect the above, you would do the following:

  Just as with the current implementation:

    "yes" and keep going:       grep { ... 1 } @a;
     "no" and keep going:       grep { ... 0 } @a;

  Exercising the new feature:

    "yes" and abort after this one:     grep { ... 1, last } @a;
     "no" and abort after this one:     grep { ... 0, last } @a;


Of course, "last" would have to be ignored in the algorithm which
determines the "last evaluated value"...

-- 
John Porter

        We're building the house of the future together.

Reply via email to