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 Cfor 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

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 object

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-19 Thread fearcadi
Damian Conway writes: David Wheeler asked: How will while behave? Cwhile 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

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 is the colon

Re: Continuations elified

2002-11-18 Thread Austin Hastings
--- Damian Conway [EMAIL PROTECTED] wrote: The semantics of Cfor 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

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

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 enable me to consistently

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

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 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 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/code/qpsmtpd/

Re: Continuations elified

2002-11-18 Thread Damian Conway
David Wheeler asked: How will while behave? Cwhile 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

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 implicit

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. Cwhile always evaluates its condition in a scalar context. Damian