Re: RFC 22 (v1) Builtin switch statement

2000-08-07 Thread Bart Lateur
On 4 Aug 2000 14:59:06 -, Perl6 RFC Librarian wrote: > %special = ( woohoo => 1, d'oh => 1 ); > >while (<>) { >switch ($_) { > >case (%special) { print "homer\n"; last } # if >$special{$_} Hold it. Is that if($special{$_}

Re: RFC 22 (v1) Builtin switch statement

2000-08-07 Thread Graham Barr
On Sat, Aug 05, 2000 at 04:10:20AM +1000, Damian Conway wrote: >> If a switch is considered like a loop then next would be the same >> as 'break' in C, as would last and redo would repeat the switch. > > But a switch is not a loop. True, but in perl any block is considered to be a loop t

Re: RFC 22 (v1) Builtin switch statement

2000-08-05 Thread Chaim Frenkel
I'm not sure it makes sense, I'd really like to get rid of the last propogating out of a sub. (or a grep/map). But if that doesn't fly, we do have Damian's new yield keyword available to do it. > "JH" == Jarkko Hietaniemi <[EMAIL PROTECTED]> writes: JH> I think we need a general way of s

Re: RFC 22 (v1) Builtin switch statement

2000-08-05 Thread Chaim Frenkel
How about adding a new keyword, hmm, 'yield'. :-) if ( grep yield $x==$_, (1,2,3) ) ... > "DC" == Damian Conway <[EMAIL PROTECTED]> writes: >> Oh, the table thing. The switch statement is useful without learning the >> complete table so I don't think complexity is a big problem. P

Re: RFC 22 (v1) Builtin switch statement

2000-08-05 Thread Jarkko Hietaniemi
On Sun, Aug 06, 2000 at 04:40:29AM +1000, Damian Conway wrote: >> Oh, the table thing. The switch statement is useful without learning the >> complete table so I don't think complexity is a big problem. People can >> learn what they need and ignore the rest. I agree with you that it mi

Re: RFC 22 (v1) Builtin switch statement

2000-08-05 Thread Damian Conway
> Oh, the table thing. The switch statement is useful without learning the > complete table so I don't think complexity is a big problem. People can > learn what they need and ignore the rest. I agree with you that it might > be nice to have an array membership operator (like "in") so

Re: RFC 22 (v1) Builtin switch statement

2000-08-05 Thread Ken Fox
Glenn Linderman wrote: > [currying] appears to be powerful, and a kind of like generic programming on > the fly. I'd like to learn more: if someone would give a tutorial > reference that would be helpful. I'll try to find something. There's a bit of computer science snobbery related to functiona

Re: RFC 22 (v1) Builtin switch statement

2000-08-05 Thread Jeremy Howard
> I haven't gotten my head around anything curried, except Indian food > but it appears to be powerful, and a kind of like generic programming on > the fly. I'd like to learn more: if someone would give a tutorial > reference that would be helpful. > A quick description is here: http://www.cs

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread skud
On Fri, Aug 04, 2000 at 05:16:15PM -0400, John Porter wrote: >Glenn Linderman wrote: >> >> This is not to detract from the ideas of higher order functions or curried >> whatever, but I >> don't think those are or should be necessary to a powerful switch statement. > >I vote thus: to have RFC 22 r

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Glenn Linderman
Ken Fox wrote: > Then write the switch as: > > switch ( __ ) { > case $v == 1: { ... } > case $v == 2: { ... } > case $v == @foo { ... } > } > > It might take you a little while to get your head around the __ > symbol. I'm not sure it's useful to think of it as a variable; > poiso

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Ken Fox
Glenn Linderman wrote: > For instance, > > if ( $v == @foo ) > > is clearly testing the size of foo against the value of $v. But > > switch ( $v ) { > case 1: { ... } > case 2: { ... } > case @foo { ... } > } > > does not! Then write the switch as: switch ( __ ) { ca

ConwayPerl (was Re: RFC 22 (v1) Builtin switch statement)

2000-08-04 Thread Jeremy Howard
Damian Conway said: > switch ( $x < __ ) { > > case 0 { print "negative" } > case 1 { print "unity" } > case any(2..9) { print "small" } > case @list { print "in range" } > } > Now _that's_ the coolest thing I've seen since, well, umm, this morning, when I read the original RFC. Damian, a lot of

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Damian Conway
> None of these perform more than one operation per pair of types. By doing the > factoring, you are constraining the type and specific value of the left hand > expression in your matching operation, limiting the set of operations that can > be performed quite severely. > >[

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Glenn Linderman
Damian Conway wrote: >> This switch statement RFC seems to be built on the premise that the >> reason to have a switch statement is to remove a common parameter >> from the following limited form conditional expressions. > > Yes. As I point out in the paper, that's the *nature* of a s

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Damian Conway
> This switch statement RFC seems to be built on the premise that the > reason to have a switch statement is to remove a common parameter > from the following limited form conditional expressions. Yes. As I point out in the paper, that's the *nature* of a switch statement. To distribute

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread John Porter
Glenn Linderman wrote: > > This is not to detract from the ideas of higher order functions or curried > whatever, but I > don't think those are or should be necessary to a powerful switch statement. I vote thus: to have RFC 22 rejected (29 rules?!), and RFC 23 accepted, with appropriate ramifica

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Glenn Linderman
This switch statement RFC seems to be built on the premise that the reason to have a switch statement is to remove a common parameter from the following limited form conditional expressions. For that reason, two new keywords are required: switch: to define the common parameter, and case: to int

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Damian Conway
> Does "goto odds" mean start evaluating all cases after the > "odds:" label? Meaning that the below is equivalent to the above? > I think this is what the original poster was asking; if not, I'd > like to ask it! That's exactly what it means. > > switch ($val) { >

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Glenn Linderman
Damian Conway wrote: >> Could a way be found to control the flow so that the next case (not always >> the one next in the order of the statment) could be executed? For example >> you have cases 1-10. You want all odd cases to also execute case 9 and the >> even cases to also execu

RE: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Lipscomb, Al
Not a bad solution, at least for the example I put forth. I like the ability to have the specific as well as the general in the case statement ('2' and '__%2 != 0'). Thanks. > Could a way be found to control the flow so that the next case (not always > the one next in the order of the stat

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Jonathan Scott Duff
On Sat, Aug 05, 2000 at 05:09:28AM +1000, Damian Conway wrote: > Not necessary. > > switch ($val) { > case 3 { print "three"; goto odds } > case 4 { print "three"; goto evens } And "goto" could be spelt "next" too? That would make sense to me,

RE: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Damian Conway
> Could a way be found to control the flow so that the next case (not always > the one next in the order of the statment) could be executed? For example > you have cases 1-10. You want all odd cases to also execute case 9 and the > even cases to also execute case 10. So in case 3 you w

RE: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Lipscomb, Al
like: pergo(9); -Original Message- From: Ted Ashton [mailto:[EMAIL PROTECTED]] Sent: Friday, August 04, 2000 2:29 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; Graham Barr Subject: Re: RFC 22 (v1) Builtin switch statement Thus it was written in the epistle of Damian Conway, > >

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread John Porter
Ted Ashton wrote: > Thus it was written in the epistle of Damian Conway, > > > > But a switch is not a loop. > > Within a loop the logic is: > > > > next -> try next case > > last -> this was the last case > > As it has already caused a little confusion, could we go with another word >

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Ted Ashton
Thus it was written in the epistle of Damian Conway, > > But a switch is not a loop. > Within a loop the logic is: > > next -> try next case > last -> this was the last case As it has already caused a little confusion, could we go with another word instead of next? 'fallthrough' se

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Jonathan Scott Duff
On Sat, Aug 05, 2000 at 04:10:20AM +1000, Damian Conway wrote: > But a switch is not a loop. > Within a loop the logic is: > > next -> try next case > last -> this was the last case And don't forget redo! redo -> reevaluate the case The block executed may have modified the

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Damian Conway
> > Howeverm it I possible to cause a C statement to > > "fall-through". If a C is executed within a C > > block, control is immediately transferred to the statement > > following the C block. > > This seems backwards to me. Everywhere else in perl next would cause the > next

Re: RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Graham Barr
On Fri, Aug 04, 2000 at 02:59:06PM -, Perl6 RFC Librarian wrote: > Howeverm it I possible to cause a C statement to "fall-through". If a > C is executed within a C block, control is immediately > transferred to the statement following the C block. > For example: > > switch ($count) {

RFC 22 (v1) Builtin switch statement

2000-08-04 Thread Perl6 RFC Librarian
=head1 TITLE Builtin switch statement =head1 VERSION Maintainer: Damian Conway <[EMAIL PROTECTED]> Date: 4 August 2000 Version: 1.00 Mailing List: [EMAIL PROTECTED] Number: 22 =head1 ABSTRACT This RFC proposes a syntax and semantics for an explicit case mechanism for Perl. The synta