Re: Loop controls

2002-04-29 Thread Allison Randal
On Tue, Apr 30, 2002 at 12:53:32PM +1000, Damian Conway wrote: > Allison wrote: > > > The answer is the same, in any case: "When the condition in the > > C has a false value, when the list/array in the C is empty, > > or when the condition (2nd expression) in the C is met on the first >

Re: Loop controls

2002-04-29 Thread Damian Conway
> OK, will at least this statement still work as it does in Perl5? No. > Notice addition of parens. which, as you surmise later, have no effect on scoping issues. > If that changes, I for one will need to go rewrite virtually every script > and library I maintain, or let p52p6 do it

Re: Loop controls

2002-04-29 Thread Miko O'Sullivan
> In Perl 6 a lexical variable is scoped to the block in which it's declared. > Since C<$cond> is declared in the block *containing* the C and C, > it's scoped to that block. So you can use it inside the C's block, > inside the C's block (assuming Larry allows such a construct), and in > the follo

Re: Loop controls

2002-04-29 Thread Damian Conway
Miko wrote: > I don't know if we're talking about the same thing, but I live using loops > that declare variables in the test, so please exegize me. Which of these > lines, if any, would cause a compiler error or warning? > > while my $cond = blah() { > ... > } > else { > print

Re: Loop controls

2002-04-29 Thread Miko O'Sullivan
> and C<$cond> is defined *outside* the block. So if Larry were to allow C > on loops, you'd be able to write: > [snip] > Given how rarely this kind of thing is actually needed (I've *never* used such > a construct), I suspect that an explicit variable is adequate. I don't know if we're talking a

Re: Loop controls

2002-04-29 Thread Damian Conway
Allison wrote: > The answer is the same, in any case: "When the condition in the > C has a false value, when the list/array in the C is empty, > or when the condition (2nd expression) in the C is met on the first ^

Re: Loop controls

2002-04-29 Thread Damian Conway
> Two solutions to the problem of accessing 'what' returned false are: > > 1) don't allow it. > 2) Alias the value of the while/loop/if conditional into a special > variable. > > while( blah() ) { > .. > } else { print $COND; } > > It's ugly, but it works, and doesn't break the holy scoping r

Re: Loop controls

2002-04-29 Thread Mike Lambert
> > > I can also think of some advantages to having the "else" within the > > > scope of the loop. > > > > while alllines("/etc/passwd") -> $_ { > > ... > > } else { > > die "/etc/passwd: $_"; > > } > > But the aliased value, $_, is restricted to the scope of th

Re: Loop controls

2002-04-29 Thread Allison Randal
On Mon, Apr 29, 2002 at 04:25:26PM -0700, Peter Scott wrote: > At 01:55 PM 4/29/02 -0500, Allison Randal wrote: > > > >There will have to be a section of the training material devoted to > >"When is a loop false?" (I like that perspective, it nicely unifies the > >cases), but it should be a short

Re: Loop controls

2002-04-29 Thread Peter Scott
At 04:15 PM 4/29/02 -0500, Allison Randal wrote: >On Mon, Apr 29, 2002 at 04:14:01PM -0400, Aaron Sherman wrote: > > > > Well then, I guess we should dump "elsif" from if too. After all, it > > could all be done with nested blocks of if/else > >But C is different. You use it all the time. The

Re: Loop controls

2002-04-29 Thread David Wheeler
On 4/29/02 1:41 PM, "Luke Palmer" <[EMAIL PROTECTED]> claimed: > My point is that, IMO, this whole "els" thing is completely preposterous. > I'm the kind of person that likes to keep down on keywords. And I never > liked Perl5's C anyway; I always preferred C. I really > don't understand what at

Re: Loop controls

2002-04-29 Thread Peter Scott
At 01:55 PM 4/29/02 -0500, Allison Randal wrote: >On Mon, Apr 29, 2002 at 10:10:01AM -0400, Aaron Sherman wrote: > > Again, it's just first derivative over time. You're not asking "is there > > a false value", you're asking "is the loop false". Just as we understand > > that an array in a conditio

Re: Loop controls

2002-04-29 Thread Damian Conway
Allison wrote: > I still don't like the idea of Cs on loops. I already do an > instant double take with C of "Where's the if?" (with visions of > old Wendy's commercials dancing in my head). It seems that a long string > of Cs (possibly separated by other long intervening sections of > code) woul

Re: Loop controls

2002-04-29 Thread Dan Kuester
The only reasonable way of doing loops is to use highly verbose syntax: #!/usr/bin/perl # sample while loop As_Long_As[0] __(*&%$ $%&*)__ begin_statement_of_syntax # 7 (spaces required) while_percha

Re: Loop controls

2002-04-29 Thread Damian Conway
Aaron Sherman wrote: > > while $result.get_next() -> $next { > > # do something with $next... > > ELSE { > ># do something otherwise with $next > > } > > } > > } > Here's the code, expanded: Unfortunately, that code isn't even close to the

Re: Loop controls

2002-04-29 Thread Damian Conway
Aaron Sherman wrote: > > Er, what?!? Who said we're dropping "until"? Did I miss something? > > Well, if there's no while (replaced by generic "loop", per Apoc4) why > would there be an until? As Aaron himself has discovered, neither C nor C is being dropped from Perl 6. Incidently, even C i

Re: Loop controls

2002-04-29 Thread Miko O'Sullivan
Concerning the els(loop|for|while) controversy, I'd like to bring it back to the point that started it all: loop-else. There seems to be a fair amount of support for a loop-else contruct. Can we/Larry decide to accept loop-else, regardless of what other decisions need to be made? It would be a

Re: Loop controls

2002-04-29 Thread Allison Randal
On Mon, Apr 29, 2002 at 04:14:01PM -0400, Aaron Sherman wrote: > > Well then, I guess we should dump "elsif" from if too. After all, it > could all be done with nested blocks of if/else But C is different. You use it all the time. The frequency with which you'd need a loop that leads into a

Re: Loop controls

2002-04-29 Thread Aaron Sherman
On Mon, 2002-04-29 at 16:41, Luke Palmer wrote: > > So, the answer to your question is: yes, I do propose that there should > > be an elsif, elsloop and elsfor. That's it. Three words, not an > > expansive list of ever-more-complex words. > > Oh! I have an idea! Why don't we make the lexer just r

Re: Loop controls

2002-04-29 Thread Luke Palmer
> So, the answer to your question is: yes, I do propose that there should > be an elsif, elsloop and elsfor. That's it. Three words, not an > expansive list of ever-more-complex words. Oh! I have an idea! Why don't we make the lexer just realize a prefix "els" on any operator. Then you could do

Re: Loop controls

2002-04-29 Thread Damian Conway
Aaron Sherman wrote: > Of course it brings other less wholesome things to mind like "elsfor" > and "elsloop" and "if ... elsfor" and "for ... elsif ... elsloop ... > else", but why not? Because Perl 6 is already...err...over-endowed with keywords, few of which are as klunky as these would be. I

Re: Loop controls

2002-04-29 Thread Jonathan E. Paton
> > I still don't like the idea of Cs on loops. I already do an > > instant double take with C of "Where's the if?" (with visions of > > old Wendy's commercials dancing in my head). > > Me too. That's why the looping "else" should be spelled "otherwise" > IMHO. If a loop produced a boolean val

Re: Loop controls

2002-04-29 Thread Aaron Sherman
On Mon, 2002-04-29 at 15:54, Jonathan Scott Duff wrote: > On Mon, Apr 29, 2002 at 03:30:40PM -0400, Aaron Sherman wrote: > > On Mon, 2002-04-29 at 10:41, Jonathan Scott Duff wrote: > > > On Mon, Apr 29, 2002 at 10:26:26AM -0400, Aaron Sherman wrote: > > > > I would expect that to be "elsuntil", bu

Re: Loop controls

2002-04-29 Thread Tanton Gibbs
What about unless? Since we are giving els to loops, shouldn't we upgrade unless as well? That would be really weird if it were not upgraded. Tanton - Original Message - From: "Jonathan Scott Duff" <[EMAIL PROTECTED]> To: "Allison Randal" <[EMAIL PROTECTED]> Cc: "Aaron Sherman" <[EMAIL

Re: Loop controls

2002-04-29 Thread Jonathan Scott Duff
On Mon, Apr 29, 2002 at 02:55:09PM -0500, Allison Randal wrote: > I still don't like the idea of Cs on loops. I already do an > instant double take with C of "Where's the if?" (with visions of > old Wendy's commercials dancing in my head). Me too. That's why the looping "else" should be spelled

Re: Loop controls

2002-04-29 Thread Aaron Sherman
On Mon, 2002-04-29 at 15:46, Miko O'Sullivan wrote: > > Well, if there's no while (replaced by generic "loop", per Apoc4) why > > would there be an until? > > Whoa. I actually had a moment of panic there. Then I checked for myself. > I don't see anything in Apoc4 about getting rid of while. It

Re: Loop controls

2002-04-29 Thread Allison Randal
On Mon, Apr 29, 2002 at 03:30:40PM -0400, Aaron Sherman wrote: > > Ok, once more for those in the cheap seats (no offense, it's just a lot > of people seemed to have ignored the thread until now and jumped in > without the context), this is how we got here: > > 1. Larry says loops will have "ELS

Re: Loop controls

2002-04-29 Thread Jonathan Scott Duff
On Mon, Apr 29, 2002 at 03:30:40PM -0400, Aaron Sherman wrote: > On Mon, 2002-04-29 at 10:41, Jonathan Scott Duff wrote: > > On Mon, Apr 29, 2002 at 10:26:26AM -0400, Aaron Sherman wrote: > > > I would expect that to be "elsuntil", but as we're dropping "until" from > > > the language, it's a moot

Re: Loop controls

2002-04-29 Thread Aaron Sherman
On Sat, 2002-04-27 at 08:53, Damian Conway wrote: > Which I presume was that the proposed usage: > > while $result.get_next() -> $next { > # do something with $next... > ELSE { > if $next eq "xyz572" { > print "We defined this value, $next, as fals

Re: Loop controls

2002-04-29 Thread Miko O'Sullivan
> Well, if there's no while (replaced by generic "loop", per Apoc4) why > would there be an until? Whoa. I actually had a moment of panic there. Then I checked for myself. I don't see anything in Apoc4 about getting rid of while. It may be excluded from evolution, but it's still there, sorta l

Re: Loop controls

2002-04-29 Thread Allison Randal
On Mon, Apr 29, 2002 at 10:26:26AM -0400, Aaron Sherman wrote: > On Fri, 2002-04-26 at 19:30, Miko O'Sullivan wrote: > > > 1) Do we have a reality check on why this syntax is needed? > > It's because the alternative is: > > Perl5: > $did = 0; > for($i=0;$i<$max;$i++) { >

Re: Loop controls

2002-04-29 Thread Aaron Sherman
On Mon, 2002-04-29 at 10:41, Jonathan Scott Duff wrote: > On Mon, Apr 29, 2002 at 10:26:26AM -0400, Aaron Sherman wrote: > > I would expect that to be "elsuntil", but as we're dropping "until" from > > the language, it's a moot point. > > Er, what?!? Who said we're dropping "until"? Did I miss

Re: Loop controls

2002-04-29 Thread Allison Randal
On Mon, Apr 29, 2002 at 10:10:01AM -0400, Aaron Sherman wrote: > On Fri, 2002-04-26 at 19:06, Allison Randal wrote: > > Absolutely what I thought. "elsif" would be for "thing else if" where > "elsfor" would be "thing else for-loop". Since you got this distinction > right off, it sounds like an in

Re: Loop controls

2002-04-29 Thread Aaron Sherman
On Sat, 2002-04-27 at 01:14, Luke Palmer wrote: > On Fri, 26 Apr 2002, Allison Randal wrote: > > > Besides, I would expect an C to actually be a loop of it's own, > > on the principle of "elsif = else + if" so "elsfor = else + for". > > So, you're suggesting we add C then? Just because it's >

Re: Loop controls

2002-04-29 Thread Luke Palmer
> See above. > > > Two issues spring to mind: > > > > 1) Do we have a reality check on why this syntax is needed? I agree it's > > cool idea, but can anyone name a real-world scenario where it would be > > useful? Can we do things just bcause they're cool? That approach didn't > > work too we

Re: Loop controls

2002-04-29 Thread Jonathan Scott Duff
On Mon, Apr 29, 2002 at 10:26:26AM -0400, Aaron Sherman wrote: > I would expect that to be "elsuntil", but as we're dropping "until" from > the language, it's a moot point. Er, what?!? Who said we're dropping "until"? Did I miss something? > Proposed Perl6: > > loop $i=0;$i<$max;$i++ {

RE: Loop controls

2002-04-29 Thread HellyerP
On Monday, April 29, 2002 3:10 PM, Aaron Sherman wrote: > On Fri, 2002-04-26 at 19:06, Allison Randal wrote: > > On Fri, Apr 26, 2002 at 05:24:13PM -0400, Aaron Sherman wrote: > > > Of course it brings other less wholesome things to mind like "elsfor" > > > and "elsloop" and "if ... elsfor" and "f

Re: Loop controls

2002-04-29 Thread Aaron Sherman
On Fri, 2002-04-26 at 19:30, Miko O'Sullivan wrote: > > Of course it brings other less wholesome things to mind like "elsfor" > > and "elsloop" and "if ... elsfor" and "for ... elsif ... elsloop ... > > else", but why not? > > Well, I agree with the concept, but boyoboy those names ain't

Re: Loop controls

2002-04-29 Thread Aaron Sherman
On Fri, 2002-04-26 at 19:06, Allison Randal wrote: > On Fri, Apr 26, 2002 at 05:24:13PM -0400, Aaron Sherman wrote: > > Of course it brings other less wholesome things to mind like "elsfor" > > and "elsloop" and "if ... elsfor" and "for ... elsif ... elsloop ... > > else", but why not? > > Urk.