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{$_}
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
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
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
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
> 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
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
> 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
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
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
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
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
> 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.
>
>[
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
> 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
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
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
> 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) {
>
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
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
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,
> 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
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,
>
>
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
>
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
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
> > 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
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) {
=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
29 matches
Mail list logo