From: Nathan Wiger [mailto:[EMAIL PROTECTED]]
> 
> Ariel Scolnicov wrote:
> > 
> > Chaim Frenkel <[EMAIL PROTECTED]> writes:
> > 
> > > yield EXPR - stop what I am doing now and give something else a
> > >               a chance to do its things. And while you are doing
> > >               that please take this EXPR from me.
> > 
> > When you put it this way, isn't C<yield> spelled C<return> in Perl5?
> > (Except, of course, that C<return> inside a C<grep> does a whole lot
> > more nowadays).
> 
> And except that C<yield> allows you to pick up where you left 
> off later, at least per Damian's RFC 31: "Co-routines". For a
> grep/map this could potentially be really useful, especially
> if you have code that modifies values in your block but want
> to do it conditionally/iteratively.

I wouldn't argue that C<yield> would be a useful in the context of C<grep>
and C<map>. But it doesn't solve the problem (RFC 199) of short-circuiting
C<grep> and C<map> if you have no intention of preserving state.

grep { 1 } 1..1_000_000;

Garrett

Reply via email to