RFC: Implicit threading and Implicit event-loop (Was: Re: Continuations)

2009-05-27 Thread Daniel Ruoso
Em Ter, 2009-05-26 às 19:33 -0700, Jon Lang escreveu: The exact semantics of autothreading with respect to control structures are subject to change over time; it is therefore erroneous to pass junctions to any control construct that is not implemented via as a normal single or multi dispatch.

Re: Continuations

2009-05-27 Thread Jon Lang
Andrew Whitworth wrote: The issue mentioned in the Synopses is that junctions autothread, and autothreading in a conditional could potentially create multiple threads of execution, all of which are taking different execution paths. At some point, to bring it all back together again, the

Re: RFC: Implicit threading and Implicit event-loop (Was: Re: Continuations)

2009-05-27 Thread John M. Dlugosz
Sounds like threads to me. What I see that's different from common threads in other languages is that they are all the same, rather than one master and many new threads that have no context history above them. In Perl 6, every thread sees the same dynamic scope as the original. It doesn't

Re: Continuations

2009-05-26 Thread John M. Dlugosz
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote: From S09, under Junctions: The exact semantics of autothreading with respect to control structures are subject to change over time; it is therefore erroneous to pass junctions to any control construct that is not implemented via as a normal

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

2002-11-20 Thread Damian Conway
Paul Johnson wrote: Is it illegal now to use quotes in qw()? Nope. Only as the very first character of a Paging Mr Cozens. ;-) It's just another instance of whitespace significance. print «\a b c»; Presumably without the backslash here too. Maybe. It depends on whether Larry

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

2002-11-19 Thread Paul Johnson
Damian Conway said: Is it illegal now to use quotes in qw()? Nope. Only as the very first character of a Paging Mr Cozens. ;-) So any of these are still fine: print a b c ; print \a b c; print «\a b c»; Presumably without the backslash here too. print

Re: Continuations

2002-11-19 Thread Austin Hastings
--- Damian Conway [EMAIL PROTECTED] wrote: Iain 'Spoon' Truskett wrote: @a ???+??? @b @a ???+??? @b Y'know, for those of us who still haven't set up Unicode, they look remarkably similar =) Think Of It As Evolution In Action ;-) This coming from someone whose national

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

2002-11-18 Thread Ken Fox
Damian Conway wrote: my $iter = fibses(); for $iter {...} (Careful with those single angles, Eugene!) Operator isn't legal when the grammar is expecting an expression, right? The must begin the circumfix operator. Is the grammar being weakened so that yacc can handle it? The rule

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

2002-11-18 Thread Damian Conway
Ken Fox wrote: Damian Conway wrote: my $iter = fibses(); for $iter {...} (Careful with those single angles, Eugene!) Operator isn't legal when the grammar is expecting an expression, right? Right. The must begin the circumfix operator. Or the circumfix ... operator.

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

2002-11-18 Thread Ken Fox
Damian Conway wrote: Ken Fox wrote: The must begin the circumfix operator. Or the circumfix ... operator. Which is the problem here. This is like playing poker with God. Assuming you can get over the little hurdles of Free Will and Omniscience, there's still the problem of Him pulling

Re: Continuations

2002-11-18 Thread Damian Conway
Ken Fox lamented: Or the circumfix ... operator. Which is the problem here. This is like playing poker with God. I hear God prefers dice. What does the circumfix ... operator do? It's the ASCII synonym for the «...» operator, which is a synonym for the qw/.../ operator. Here docs are

Re: Continuations

2002-11-18 Thread Ken Fox
Damian Conway wrote: It's [...] the ASCII synonym for the «...» operator, which is a synonym for the qw/.../ operator. Nope. Heredocs still start with . Hey! Where'd *that* card come from? ;) Seriously, that's a good trick. How does it work? What do these examples do? print a b c;

Re: Continuations

2002-11-18 Thread Damian Conway
Seriously, that's a good trick. How does it work? What do these examples do? print a b c; Squawks about finding the string b immediately after the heredoc introducer. print a b c; Likewise. Is it illegal now to use quotes in qw()? Nope. Only as the very first

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

2002-11-18 Thread Luke Palmer
Date: Tue, 19 Nov 2002 14:29:46 +1100 From: Damian Conway [EMAIL PROTECTED] Ken Fox lamented: Or the circumfix ... operator. Which is the problem here. This is like playing poker with God. I hear God prefers dice. What does the circumfix ... operator do? It's the ASCII

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

Re: Continuations

2002-11-18 Thread Damian Conway
Luke Palmer asked: What was the final syntax for vector ops? @a ≪+≫ @b @a ≫+≪ @b The latter (this week, at least ;-). Damian

Re: Continuations

2002-11-18 Thread Iain 'Spoon' Truskett
* Damian Conway ([EMAIL PROTECTED]) [19 Nov 2002 15:19]: Luke Palmer asked: What was the final syntax for vector ops? @a ???+??? @b @a ???+??? @b The latter (this week, at least ;-). Y'know, for those of us who still haven't set up Unicode, they look remarkably similar =)

Re: Continuations elified

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

Re: Continuations

2002-11-18 Thread Damian Conway
Iain 'Spoon' Truskett wrote: @a ???+??? @b @a ???+??? @b Y'know, for those of us who still haven't set up Unicode, they look remarkably similar =) Think Of It As Evolution In Action ;-) Damian

Re: Continuations

2002-11-18 Thread David Wheeler
On Monday, November 18, 2002, at 08:19 PM, Damian Conway wrote: (B (B What was the final syntax for vector ops? (B @a $B"c(B+$B"d(B @b (B @a $B"d(B+$B"c(B @b (B (B The latter (this week, at least ;-). (B (BThis reminds me: I though of another set of bracing characters that

RE: Continuations

2002-11-17 Thread Angel Faus
Damian Conway wrote: The formulation of coroutines I favour doesn't work like that. Every time you call a suspended coroutine it resumes from immediately after the previous Cyield than suspended it. *And* that Cyield returns the new argument list with which it was resumed. So you can write

Re: Continuations

2002-11-17 Thread Dan Sugalski
At 1:29 PM +1100 11/17/02, Damian Conway wrote: The formulation of coroutines I favour doesn't work like that. Every time you call a suspended coroutine it resumes from immediately after the previous Cyield than suspended it. *And* that Cyield returns the new argument list with which it was

Re: Continuations

2002-11-17 Thread Damian Conway
Angel Faus wrote: I understand that this formulation is more powefull, but one thing I like about python's way (where a coroutine is just a funny way to generate lazy arrays) is that it lets you _use_ coroutines without even knowing what they are about. Such as when you say: for $graph.nodes {

Re: Continuations

2002-11-17 Thread Damian Conway
Of course, apart from the call-with-new-args behaviour, having Pythonic coroutines isn't noticably less powerful. Given: sub fibs ($a = 0 is copy, $b = 1 is copy) { loop { yield $b; ($a, $b) = ($b, $a+b); } } we still have implicit iteration:

Re: Continuations

2002-11-17 Thread Luke Palmer
Date: Mon, 18 Nov 2002 09:28:59 +1100 From: Damian Conway [EMAIL PROTECTED] I've a couple of questions here: we still have implicit iteration: for fibs() { print Now $_ rabbits\n; } Really? What if fibs() is a coroutine that returns lists (Fibonacci lists, no less),

Re: Continuations

2002-11-17 Thread Damian Conway
Luke Palmer enquired: we still have implicit iteration: for fibs() { print Now $_ rabbits\n; } Really? What if fibs() is a coroutine that returns lists (Fibonacci lists, no less), and you just want to iterate over one of them? The syntax: for fibs { print Now

Re: Continuations

2002-11-16 Thread Damian Conway
Peter Haworth asked: So to get the same yield context, each call to the coroutine has to be from the same calling frame. If you want to get several values from the same coroutine, but from different calling contexts, can you avoid the need to wrap it in a closure? I don't think so. Damian

Re: Continuations

2002-11-16 Thread Dan Sugalski
At 8:31 AM +1100 11/17/02, Damian Conway wrote: Peter Haworth asked: So to get the same yield context, each call to the coroutine has to be from the same calling frame. If you want to get several values from the same coroutine, but from different calling contexts, can you avoid the need to wrap

Re: Continuations

2002-11-16 Thread Damian Conway
Dan Sugalski wrote: I dunno. One of the things I've seen with coroutines is that as long as you call them with no arguments, you get another iteration of the coroutine--you actually had to call it with new arguments to reset the thing. The formulation of coroutines I favour doesn't work

Re: Continuations

2002-11-12 Thread Peter Haworth
On Wed, 06 Nov 2002 10:38:45 +1100, Damian Conway wrote: Luke Palmer wrote: I just need a little clarification about yield(). Cyield is exactly like a Creturn, except that when you call the subroutine next time, it resumes from after the Cyield. how do you tell the difference between a

Re: Continuations for fun and profit

2002-07-09 Thread Ted Zlatanov
On Mon, 8 Jul 2002, [EMAIL PROTECTED] wrote: Yep. But serializing continuations is either tough, or not completely doable, since programs tend to have handles on things outside their direct control like filehandles, sockets, database connections, and suchlike things. Resuming a continuation

Re: Continuations for fun and profit

2002-07-09 Thread Peter Haworth
On Mon, 8 Jul 2002 16:54:16 -0400, Dan Sugalski wrote: while ($foo) { $foo--; } Pretty simple. (For illustrative purposes) To do that with continuations, it'd look like: $cont = take_continuation(); if ($foo) { $foo--; invoke($cont); } When

Re: Continuations for fun and profit

2002-07-09 Thread Peter Haworth
On Tue, 9 Jul 2002 16:42:03 +0100, Peter Haworth wrote: When you invoke a continuation you put the call scratchpads and lexical scratchpads back to the state they were when you took the continuation. If you restore the lexicals, how does this ever finish? Never mind. It's the *access* to

Re: Continuations for fun and profit

2002-07-08 Thread David M. Lloyd
On Mon, 8 Jul 2002, Dan Sugalski wrote: Pretty simple. (For illustrative purposes) To do that with continuations, it'd look like: $cont = take_continuation(); if ($foo) { $foo--; invoke($cont); } take_continuation() returns a continuation for the current point

Re: Continuations for fun and profit

2002-07-08 Thread Nicholas Clark
On Mon, Jul 08, 2002 at 04:54:16PM -0400, Dan Sugalski wrote: Pretty simple. (For illustrative purposes) To do that with continuations, it'd look like: $cont = take_continuation(); if ($foo) { $foo--; invoke($cont); } take_continuation() returns a continuation for

Re: Continuations for fun and profit

2002-07-08 Thread Peter Scott
At 04:54 PM 7/8/02 -0400, Dan Sugalski wrote: A continuation is a sort of super-closure. Like a closure it captures its lexical variables, so every time you use it, you're referring to the same set of variables, which live on until the continuation's destroyed. This works because the variables

Re: Continuations for fun and profit

2002-07-08 Thread Dan Sugalski
At 3:01 PM -0700 7/8/02, Peter Scott wrote: At 04:54 PM 7/8/02 -0400, Dan Sugalski wrote: A continuation is a sort of super-closure. Like a closure it captures its lexical variables, so every time you use it, you're referring to the same set of variables, which live on until the continuation's

Re: Continuations for fun and profit

2002-07-08 Thread Dan Sugalski
At 10:24 PM +0100 7/8/02, Nicholas Clark wrote: On Mon, Jul 08, 2002 at 04:54:16PM -0400, Dan Sugalski wrote: Pretty simple. (For illustrative purposes) To do that with continuations, it'd look like: $cont = take_continuation(); if ($foo) { $foo--; invoke($cont);

Re: Continuations for fun and profit

2002-07-08 Thread Ted Ashton
Thus it was written in the epistle of Peter Scott, So if you could serialize a continuation, you could freeze your program state to disk and restore it later? Cool, makes for easy checkpoint/restarts. I think that that would be true only if *all* data was maintained in those scratchpads