Re: Coroutines, continuations, and iterators -- oh, my! (Was: Re: Continuations elified)

2002-11-21 Thread fearcadi
Damian Conway writes: > > There's no second iterator. Just C walking through an array. > ( questions in the form of answers :-) so : * "for" impose array context for first argument and doesnt care about "nature" of the array which it was given eventually as an argument . no multiple st

Re: Coroutines, continuations, and iterators -- oh, my! (Was: Re: Continuations elified)

2002-11-20 Thread Damian Conway
Austin Hastings wrote: for each $dance: { ^ note colon 1- Why is the colon there? Is this some sub-tile syntactical new-ance that I missed in a prior message, or a new thing? It's the way we mark an indirect object in Perl 6. 2- Why is the colon necessary? Isn't the "

Re: Continuations elified

2002-11-20 Thread Damian Conway
Arcadi wrote: > > > > while <$iter> {...} # Iterate until $iter.each returns false? > you mean "Iterate until $iter.next returns false?" Oops. Quite so. what is the difference between the Iterator and lazy array ? am I right that it is just "interface" : lazy array is an iterator

Re: Coroutines, continuations, and iterators -- oh, my! (Was: Re: Continuations elified)

2002-11-19 Thread Austin Hastings
> Larry wrote: > > So you can do it any of these ways: > > for <$dance> { > > for $dance.each { > > for each $dance: { >^ note colon 1- Why is the colon there? Is this some sub-tile syntactical new-ance that I missed in a prior message, or a new thing? 2- Why i

Re: Continuations elified

2002-11-19 Thread fearcadi
Damian Conway writes: > David Wheeler asked: > > > How will while behave? > > C evaluates its first argument in scalar context, so: > > > > while <$fh> {...}# Iterate until $fh.readline returns EOF? > > More or less. Technically: call <$fh.next> and execute the loop > body i

Re: Continuations elified

2002-11-18 Thread David Wheeler
On Monday, November 18, 2002, at 08:17 PM, Damian Conway wrote: Sure. C always evaluates its condition in a scalar context. Oh, duh. Thanks. David -- David Wheeler AIM: dwTheory [EMAIL PROTECTED] ICQ: 15726394 http://david.w

Re: Continuations elified

2002-11-18 Thread Damian Conway
David Wheeler asked: while <$fh> {...}# Iterate until $fh.readline returns EOF? That's a scalar context? Sure. C always evaluates its condition in a scalar context. Damian

Re: Continuations elified

2002-11-18 Thread David Wheeler
On Monday, November 18, 2002, at 08:05 PM, Damian Conway wrote: while <$fh> {...}# Iterate until $fh.readline returns EOF? More or less. Technically: call <$fh.next> and execute the loop body if that method returns true. Whether it still has the automatic binding to $_ and the implic

Re: Continuations elified

2002-11-18 Thread Damian Conway
David Wheeler asked: How will while behave? C evaluates its first argument in scalar context, so: while <$fh> {...}# Iterate until $fh.readline returns EOF? More or less. Technically: call <$fh.next> and execute the loop body if that method returns true. Whether it still has the au

Re: Continuations elified

2002-11-18 Thread Luke Palmer
> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm > X-Sent: 19 Nov 2002 02:51:54 GMT > Date: Tue, 19 Nov 2002 13:51:56 +1100 > From: Damian Conway <[EMAIL PROTECTED]> > X-Accept-Language: en, en-us > Cc: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > X-SMTPD: qpsmtpd/0.12, http://develooper.com/co

Re: Continuations elified

2002-11-18 Thread David Wheeler
On Monday, November 18, 2002, at 06:51 PM, Damian Conway wrote: for <$fh> {...}# Build and then iterate a lazy array (the elements # of which call back to the filehandle's input # retrieval coroutine) for <$iter> {...} # Build and then iterate a lazy array (the elements

Re: Continuations elified

2002-11-18 Thread Damian Conway
Larry wrote: So you can do it any of these ways: for <$dance> { for $dance.each { for each $dance: { ^ note colon Then there's this approach to auto-iteration: my @dance := Iterator.new(@squares); for @dance { Okay, so now I need to make sense of the

Re: Continuations elified

2002-11-18 Thread Larry Wall
On Tue, Nov 19, 2002 at 08:53:17AM +1100, Damian Conway wrote: : my $dance = Iterator.new(@squares); : for $dance { Scalar variables have to stay scalar in list context, so $dance cannot suddenly start behaving like a list. Something must tell the scalar to behave like a list, and I don't

Re: Continuations elified

2002-11-18 Thread Austin Hastings
--- Damian Conway <[EMAIL PROTECTED]> wrote: > Austin Hastings asked: > > That is, can I say > > > > for (@squares) > > { > > ... > > if $special.instructions eq 'Advance three spaces' > > { > > $_.next.next.next; > > } > > ... > > } > > > > or some other suchlike thing that will

Re: Continuations elified

2002-11-18 Thread Damian Conway
Austin Hastings asked: By extension, if it is NOT given an iterator object, will it appear to create one? Yep. That is, can I say for (@squares) { ... if $special.instructions eq 'Advance three spaces' { $_.next.next.next; } ... } or some other suchlike thing that will enab

Re: Continuations elified

2002-11-18 Thread Austin Hastings
--- Damian Conway <[EMAIL PROTECTED]> wrote: > The semantics of C would simply be that if it is given an > iterator object (rather than a list or array), then it calls > that object's iterator once per loop. By extension, if it is NOT given an iterator object, will it appear to create one? That