Re: Control flow variables

2003-11-25 Thread Piers Cawley
Simon Cozens [EMAIL PROTECTED] writes: Luke Palmer: So modules that introduce new concepts into the language can add new syntax for them without working with (ugh) a source filter. And some of these new syntaxes in the core language will actually be in standard modules, if they're not

Re: Control flow variables

2003-11-25 Thread Luke Palmer
Piers Cawley writes: Simon Cozens [EMAIL PROTECTED] writes: But it isn't, and I don't know why it isn't, and so we end up spending loads of time discussing things that can be punted out to modules. Designing Perl 6 is hard enough; let's not try to fill CP6AN at the same time. But the

Re: Control flow variables

2003-11-21 Thread Jonathan Scott Duff
On Thu, Nov 20, 2003 at 03:26:36PM -0700, Luke Palmer wrote: No. gather{} is a generator (assuming nothing about its name or existance whatsoever). It runs some code, gathering up each pick() (same assumption) into a list, and returning that. Thanks for the post Luke. I'd seen what Larry

Re: Control flow variables

2003-11-21 Thread Larry Wall
On Thu, Nov 20, 2003 at 07:27:56PM -0600, Jonathan Scott Duff wrote: : On Thu, Nov 20, 2003 at 03:26:36PM -0700, Luke Palmer wrote: : One wonders what the return value of a loop will be: : : my $what = do { : while $cond {...} : } : : I would expect it to be the value of the

Re: Parsing macros (was: Control flow variables)

2003-11-20 Thread Luke Palmer
Jonathan Lang writes: Larry Wall wrote: So far we've only allowed is parsed on the macro itself, not on individual arguments. Still, that's an interesting idea. Forgive me if this has already been addressed, but this could have some useful applications: So far, everything I've read

Re: Control flow variables

2003-11-20 Thread Smylers
Larry Wall writes: And nested modifiers are still quite illegal in Standard Perl 6. Right. Anybody else get the feeling we should write that down somewhere, so we don't have to have this conversation again in a few months? Smylers

Re: Control flow variables

2003-11-20 Thread Smylers
Larry Wall writes: On Wed, Nov 19, 2003 at 08:08:49AM +1100, Damian Conway wrote: : Michael Lazzaro wrote: : : return if $a { $a } : : Means: : :if ($a) { return $a } else { return undef } No, it's a syntax error. You must write return do { if $a { $a } } to

Re: Control flow variables

2003-11-20 Thread Jonathan Scott Duff
On Wed, Nov 19, 2003 at 12:49:21PM -0800, Larry Wall wrote: Sorry, I wasn't being very clear. It wouldn't be logically attached to the outside of the for, but to the inside of the confer, or whatever: @foo = gather { for @a - $x { pick $x if mumble($x) } DEFAULT { @results

Re: Control flow variables

2003-11-20 Thread Piers Cawley
Smylers [EMAIL PROTECTED] writes: Larry Wall writes: And nested modifiers are still quite illegal in Standard Perl 6. Right. Anybody else get the feeling we should write that down somewhere, so we don't have to have this conversation again in a few months? It'll be in the summary.

Re: Control flow variables

2003-11-20 Thread Michael Lazzaro
On Tuesday, November 18, 2003, at 12:15 PM, Luke Palmer wrote: Oh, and if you really want to do that return thing without using a Cgiven, you can just: sub blah { return $a || goto CONT; CONT: ... } I don't see what's wrong with that. :-p Umm... refresh my/our memory.

Anonymous Multi's? [was Re: Control flow variables]

2003-11-20 Thread Dave Whipp
Larry Wall [EMAIL PROTECTED] wrote: Also, since multi is orthogonal to naming ... So I'm wondering what the correct syntax is to grab a reference to a group of multi-somethings. Example: multi sub foo(Int $a:) {...}; multi sub foo(String $a:) {...}; my $ref = multi foo; $ref(hello); # calls

Re: Anonymous Multi's? [was Re: Control flow variables]

2003-11-20 Thread Dan Sugalski
On Thu, 20 Nov 2003, Dave Whipp wrote: Larry Wall [EMAIL PROTECTED] wrote: Also, since multi is orthogonal to naming ... So I'm wondering what the correct syntax is to grab a reference to a group of multi-somethings. While Larry will probably weigh in on this, I'd rather you not actually

Re: Control flow variables

2003-11-20 Thread Luke Palmer
Jonathan Scott Duff writes: On Wed, Nov 19, 2003 at 12:49:21PM -0800, Larry Wall wrote: Sorry, I wasn't being very clear. It wouldn't be logically attached to the outside of the for, but to the inside of the confer, or whatever: @foo = gather { for @a - $x { pick $x if

Re: Control flow variables

2003-11-19 Thread Jonathan Scott Duff
On Tue, Nov 18, 2003 at 11:05:57AM -0800, Michael Lazzaro wrote: On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote: Given that we've introduced the concept of if having a return status: my $result = if ($a) { $a } else { $b }; Would that then imply that sub blah {

RE: Control flow variables

2003-11-19 Thread Gordon Henriksen
[mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 2:06 PM To: [EMAIL PROTECTED] Subject: Re: Control flow variables On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote: Given that we've introduced the concept of if having a return status: my $result

Re: Control flow variables

2003-11-19 Thread Smylers
Michael Lazzaro writes: [EMAIL PROTECTED] (Dan Sugalski) writes: Luke Palmer: That's illegal anyway. Can't chain statement modifiers :-) Will be able to. I was under the strong impression that Larry had decided that syntactic ambiguities prevented this from happening. I also

Re: Control flow variables

2003-11-19 Thread Jonathan Scott Duff
On Tue, Nov 18, 2003 at 11:37:22PM +0100, Seiler Thomas wrote: So... lets call a function instead: my $is_ok = 1; for 0..6 - $t { if abs(@new[$t] - @new[$t+1]) 3 { $is_ok = 0; last; } } if $is_ok { yada() # has

RE: Control flow variables

2003-11-19 Thread Gordon Henriksen
Austin Hastings wrote: I'm way not sure about how the vector context result of iteration structures will work. Specifically, what happens when a loop forks a thread, or passes to a parallelized coroutine? There may not actually BE a result. (Of course, in a right-thinking system this will be

RE: Control flow variables

2003-11-19 Thread Gordon Henriksen
Damian Conway wrote: push @moves, [$i, $j]; for 0..6 - $t { if abs(@new[$t] - @new[$t+1]) 3 { pop @moves; last; } } Thomas Seiler writes: my $is_ok = 1; for 0..6 - $t { if abs(@new[$t] - @new[$t+1]) 3 { $is_ok = 0; last; }

RE: Control flow variables

2003-11-19 Thread Austin Hastings
Austin Hastings wrote: I'm way not sure about how the vector context result of iteration structures will work. Specifically, what happens when a loop forks a thread, or passes to a parallelized coroutine? There may not actually BE a result. (Of course, in a right-thinking system this

Re: Control flow variables

2003-11-19 Thread Randal L. Schwartz
Smylers == Smylers [EMAIL PROTECTED] writes: Smylers I also was under the strong impression that Larry had decreed Smylers that we wouldn't have chained statement modifiers ... but I Smylers thought it was because Larry had decided they would be a bad Smylers thing to have rather than because

RE: Control flow variables

2003-11-19 Thread Austin Hastings
-Original Message- From: Randal L. Schwartz [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 19, 2003 9:46 AM To: [EMAIL PROTECTED] Subject: Re: Control flow variables Smylers == Smylers [EMAIL PROTECTED] writes: Smylers I also was under the strong impression that Larry

Re: Control flow variables

2003-11-19 Thread Randal L. Schwartz
Randal == Randal L Schwartz [EMAIL PROTECTED] writes: Randal I actually consider that an annoying statement. I have to back up Randal three times to figure out what it means. And before someone whips out the Schwartzian Transform to undermine my statement... please note that in Perl6, you'll

Re: Control flow variables

2003-11-19 Thread Luke Palmer
Piers Cawley writes: All of which means you can wrap it up in a macro and prove Simon's point about what's syntax and what's CP6AN: macro unless_all( Block test is parsed /perl.expression/, Block consequence, [EMAIL PROTECTED] ) { my $guard = Object.new;

Re: Control flow variables

2003-11-19 Thread Larry Wall
On Wed, Nov 19, 2003 at 08:08:49AM +1100, Damian Conway wrote: : Michael Lazzaro wrote: : : So, just to make sure, these two lines are both valid, but do completely : different things: : : return if $a; : : Means: : : if ($a) { return } : : : return if $a { $a } : : Means: : :

Re: Control flow variables

2003-11-19 Thread Larry Wall
On Wed, Nov 19, 2003 at 09:30:15AM -0700, Luke Palmer wrote: : Piers Cawley writes: : All of which means you can wrap it up in a macro and prove Simon's : point about what's syntax and what's CP6AN: : : macro unless_all( Block test is parsed /perl.expression/, : Block

RE: Control flow variables

2003-11-19 Thread Gordon Henriksen
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

Re: Control flow variables

2003-11-19 Thread Luke Palmer
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

Re: Control flow variables

2003-11-19 Thread Larry Wall
On Wed, Nov 19, 2003 at 09:12:01AM -0600, Jonathan Scott Duff wrote: : On Tue, Nov 18, 2003 at 09:36:31PM -0800, Larry Wall wrote: : As for the original question that started this whole silly thread, : control structures that return values should probably be considered : some kind of generator,

RE: Control flow variables

2003-11-19 Thread Austin Hastings
-Original Message- From: Larry Wall [mailto:[EMAIL PROTECTED] On the other hand, putting the default up front is clearer if the block is long. Could even be something like: @foo = gather is default(@results) { for @a - $x { pick $x if mumble($x) } } And Cgather is

Re: Control flow variables

2003-11-19 Thread Sean O'Rourke
[EMAIL PROTECTED] (Austin Hastings) writes: What does Cscatter do? That's the operator that's used to assign values to C$^x and friends in closures. In all its glory, you give it a set of values, and it assigns them to a block's undefined variables, quieting those annoying warnings: @x =

Parsing macros (was: Control flow variables)

2003-11-19 Thread Jonathan Lang
Larry Wall wrote: So far we've only allowed is parsed on the macro itself, not on individual arguments. Still, that's an interesting idea. Forgive me if this has already been addressed, but this could have some useful applications: So far, everything I've read about macro parsing concentrates

Control flow variables

2003-11-18 Thread Luke Palmer
I was reading the most recent article on perl.com, and a code segment reminded me of something I see rather often in code that I don't like. Here's the code, Perl6ized: ... ; my $is_ok = 1; for 0..6 - $t { if abs(@new[$t] - @new[$t+1]) 3 { $is_ok = 0;

Re: Control flow variables

2003-11-18 Thread Simon Cozens
[EMAIL PROTECTED] (Luke Palmer) writes: I was reading the most recent article on perl.com, and a code segment reminded me of something I see rather often in code that I don't like. The code in question got me thinking too; I wanted to find a cleaner way to write it, but didn't see one. So, in

Re: Control flow variables

2003-11-18 Thread Luke Palmer
Simon Cozens writes: [EMAIL PROTECTED] (Luke Palmer) writes: I was reading the most recent article on perl.com, and a code segment reminded me of something I see rather often in code that I don't like. The code in question got me thinking too; I wanted to find a cleaner way to write it,

Re: Control flow variables

2003-11-18 Thread Simon Cozens
Luke Palmer: Well... it is and isn't. At first sight, it makes the language look huge, the parser complex, a lot of syntax to master, etc. It also seems to me that there is little discrimination when adding new syntax. Correct. But I've come to look at it another way. Perl 6 is doing

Re: Control flow variables

2003-11-18 Thread Dan Sugalski
On Tue, 18 Nov 2003, Simon Cozens wrote: Luke Palmer: That's illegal anyway. Can't chain statement modifiers :-) Bah, should be able to! Will be able to. Dan --it's like this--- Dan Sugalski

Re: Control flow variables

2003-11-18 Thread Simon Cozens
[EMAIL PROTECTED] (Dan Sugalski) writes: Luke Palmer: That's illegal anyway. Can't chain statement modifiers :-) Will be able to. I thought as much; Perl 6 will only be finally finished when the biotech is sufficiently advanced to massively clone Larry... -- quidity Sometimes it's better

RE: Control flow variables

2003-11-18 Thread Austin Hastings
-Original Message- From: Luke Palmer [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 9:21 AM To: Language List Subject: Control flow variables I was reading the most recent article on perl.com, and a code segment reminded me of something I see rather often in code

Re: Control flow variables

2003-11-18 Thread Luke Palmer
Austin Hastings writes: Luke Palmer wrote: I was reading the most recent article on perl.com, and a code segment reminded me of something I see rather often in code that I don't like. Here's the code, Perl6ized: ... ; my $is_ok = 1; for 0..6 - $t { if

Re: Control flow variables

2003-11-18 Thread Dan Sugalski
On Tue, 18 Nov 2003, Simon Cozens wrote: [EMAIL PROTECTED] (Dan Sugalski) writes: Luke Palmer: That's illegal anyway. Can't chain statement modifiers :-) Will be able to. I thought as much; Perl 6 will only be finally finished when the biotech is sufficiently advanced to massively

Re: Control flow variables

2003-11-18 Thread Simon Cozens
[EMAIL PROTECTED] (Austin Hastings) writes: This is what I was talking about when I mentioned being able to do: cleanup .= { push @moves: [$i, $j]; } This reminds me of something I thought the other day might be useful: $cleanup = bless {}, class { method DESTROY { ... } };

Re: Control flow variables

2003-11-18 Thread Dan Sugalski
On Tue, 18 Nov 2003, Simon Cozens wrote: [EMAIL PROTECTED] (Austin Hastings) writes: This is what I was talking about when I mentioned being able to do: cleanup .= { push @moves: [$i, $j]; } This reminds me of something I thought the other day might be useful: $cleanup = bless {},

RE: Control flow variables

2003-11-18 Thread Austin Hastings
-Original Message- From: Luke Palmer [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 10:49 AM To: Austin Hastings Cc: Language List Subject: Re: Control flow variables Austin Hastings writes: Luke Palmer wrote: I was reading the most recent article on perl.com

Re: Control flow variables

2003-11-18 Thread Mark A. Biggar
OOPS, totally miss-read your code, ignore my first part of my last message. -- [EMAIL PROTECTED] [EMAIL PROTECTED]

Re: Control flow variables

2003-11-18 Thread Mark A. Biggar
Luke Palmer wrote: I was reading the most recent article on perl.com, and a code segment reminded me of something I see rather often in code that I don't like. Here's the code, Perl6ized: ... ; my $is_ok = 1; for 0..6 - $t { if abs(@new[$t] - @new[$t+1]) 3 {

Re: Control flow variables

2003-11-18 Thread Michael Lazzaro
On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote: Given that we've introduced the concept of if having a return status: my $result = if ($a) { $a } else { $b }; Would that then imply that sub blah { ... # 1 return if $a;# 2 ...

RE: Control flow variables

2003-11-18 Thread Austin Hastings
-Original Message- From: Michael Lazzaro [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 2:06 PM To: [EMAIL PROTECTED] Subject: Re: Control flow variables On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote: Given that we've introduced the concept

Re: Control flow variables

2003-11-18 Thread Luke Palmer
Austin Hastings writes: -Original Message- From: Michael Lazzaro [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 2:06 PM To: [EMAIL PROTECTED] Subject: Re: Control flow variables On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote: Given

Re: Control flow variables

2003-11-18 Thread Luke Palmer
Austin Hastings writes: -Original Message- From: Michael Lazzaro [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 2:06 PM To: [EMAIL PROTECTED] Subject: Re: Control flow variables On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote: Given

Re: Control flow variables

2003-11-18 Thread Michael Lazzaro
Would that then imply that sub blah { ... # 1 return if $a;# 2 ... # 3 } ...would return $a if $a was true, and fall through to (3) if it was false? It sure should, provided there were a correct context waiting, which would quite

Re: Control flow variables

2003-11-18 Thread Damian Conway
Luke Palmer started a discussion: I see this idiom a lot in code. You loop through some values on a condition, and do something only if the condition was never true. $is_ok is a control flow variable, something I like to minimize. Now, there are other ways to do this: if (0..6 == grep - $t

Re: Control flow variables

2003-11-18 Thread Damian Conway
Michael Lazzaro wrote: So, just to make sure, these two lines are both valid, but do completely different things: return if $a; Means: if ($a) { return } return if $a { $a } Means: if ($a) { return $a } else { return undef } Damian

RE: Control flow variables

2003-11-18 Thread Austin Hastings
-Original Message- From: Damian Conway [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 4:02 PM To: Language List Subject: Re: Control flow variables Luke Palmer started a discussion: I see this idiom a lot in code. You loop through some values on a condition

RE: Control flow variables

2003-11-18 Thread Austin Hastings
-Original Message- From: Luke Palmer [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 3:11 PM To: Austin Hastings Cc: Michael Lazzaro; [EMAIL PROTECTED] Subject: Re: Control flow variables Austin Hastings writes: -Original Message- From: Michael

RE: Control flow variables

2003-11-18 Thread Dan Sugalski
On Tue, 18 Nov 2003, Austin Hastings wrote: This seems excessive, but easily discarded during optimization. On the other hand, I don't trust the last statement evaluated behavior for loops, since the optimizer could very well do surprising things to loop statements. (Likewise, however, for

Re: Control flow variables

2003-11-18 Thread Luke Palmer
Austin Hastings writes: From: Luke Palmer [mailto:[EMAIL PROTECTED] Austin Hastings writes: From: Michael Lazzaro [mailto:[EMAIL PROTECTED] Would that then imply that sub blah { ... # 1 return if $a;# 2 ...

Re: Control flow variables

2003-11-18 Thread Damian Conway
Luke Palmer wrote: My Cif/Cunless typo may have misled you, but the original example pushed only if *none* of them passed the condition. Ah, sorry, I misunderstood. So you want: push @moves, [$i, $j]; for 0..6 - $t { if abs(@new[$t] - @new[$t+1]) 3 { pop @moves;

RE: Control flow variables

2003-11-18 Thread Austin Hastings
-Original Message- From: Dan Sugalski [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 4:34 PM To: Language List Subject: RE: Control flow variables On Tue, 18 Nov 2003, Austin Hastings wrote: This seems excessive, but easily discarded during optimization

Re: Control flow variables

2003-11-18 Thread Seiler Thomas
Damian Conway wrote: push @moves, [$i, $j]; for 0..6 - $t { if abs(@new[$t] - @new[$t+1]) 3 { pop @moves; last; } } Indeed, an elegant way around the problem. So... lets call a function instead: my $is_ok = 1; for 0..6

Re: Control flow variables

2003-11-18 Thread Damian Conway
Seiler Thomas wrote: So... lets call a function instead: my $is_ok = 1; for 0..6 - $t { if abs(@new[$t] - @new[$t+1]) 3 { $is_ok = 0; last; } } if $is_ok { yada() # has sideeffects... } That's just: for 0..6, 'ok' - $t

Re: Control flow variables

2003-11-18 Thread Damian Conway
Joseph Ryan wrote: Not to be a jerk, but how about: my $is_ok = 1; for @array_of_random_values_and_types - $t { if not some_sort_of_test($t) { $is_ok = 0; last; } } if $is_ok { yada() # has sideeffects... } That's just: given

Re: Control flow variables

2003-11-18 Thread David Wheeler
On Tuesday, November 18, 2003, at 06:11 PM, Joseph Ryan wrote: Not to be a jerk, but how about: my $is_ok = 1; for @array_of_random_values_and_types - $t { if not some_sort_of_test($t) { $is_ok = 0; last; } } if $is_ok { yada() # has

Re: Control flow variables

2003-11-18 Thread Joseph Ryan
David Wheeler wrote: On Tuesday, November 18, 2003, at 06:11 PM, Joseph Ryan wrote: Not to be a jerk, but how about: my $is_ok = 1; for @array_of_random_values_and_types - $t { if not some_sort_of_test($t) { $is_ok = 0; last; } } if $is_ok {

Re: Control flow variables

2003-11-18 Thread Damian Conway
David Wheeler wrote: Isn't that just: for @array_of_random_values_and_types, 'ok' - $t { when 'ok' { yada(); last } last unless some_sort_of_test($t); } IOW, the topic is only 'ok' when all of the items in the array have been processed Unless, of course, the string 'ok'

Re: Control flow variables

2003-11-18 Thread David Wheeler
On Tuesday, November 18, 2003, at 06:44 PM, Joseph Ryan wrote: And also if @array_of_random_values contains 'ok'. D'oh! See Damian's solution, then. ;-) David -- David Wheeler AIM: dwTheory [EMAIL PROTECTED] ICQ: 15726394