develooper Front page | perl.perl6.language | Postings from November 2003

Re: Control flow variables

Thread Previous | Thread Next
From:
Luke Palmer
Date:
November 19, 2003 12:28
Subject:
Re: Control flow variables
Message ID:
20031119202756.GA13742@babylonia.flatirons.org
Gordon Henriksen writes:
> Larry Wall wrote:
> 
> > On Tue, Nov 18, 2003 at 06:28:59PM -0500, Gordon Henriksen wrote:
> > 
> > >     my @b = for @a -> $_ {
> > >         ...
> > >     }
> > 
> > That will be a syntax error. Generators are too mind-stretching to
> > inflict on novices [...]
> 
> I making the point that within the context of this we-wish-loops-were-
> expressions discussion, the "for expression" was simply another way
> to spell map, at least when autoiterating an array.
> 
> I certainly wasn't thinking in terms of coroutines--they absolutely
> deserve a large syntactic barrier.

I don't think generate{} and yield() were supposed to indicate
coroutines.  Instead, it's more like Mathematica's Sow[] and Reap[],
which would work (Perl6-ized) as follows:

    @a = reap { 
        sow 1;
        some-other-statement;
        sow 2;
    }  # @a is (1,2)

It's a nice concept; it simplifies certain kinds of list processing
greatly.  It would easily be implemented with coroutines, which might
also explain the yield().

Luke


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