D - Perl 6 Switch Statement
- Kublai Kahn (17/17) Feb 25 2003 Perl 6 has a new switch statement called "given."
- anderson (11/28) Mar 01 2003 and
Perl 6 has a new switch statement called "given." In Perl 5 there was no switch statement because the designer of Perl wanted to create the right statement. The Perl 6 is denoted by given and the case is denoted by when. There is even syntax for exceptions. http://dev.perl.org/perl6/apocalypse/4 A typical Perl 6 "Switch" statement would be: given statement { when condition { } when condition { } } A typical Perl 6 Exception would be catch exception { when { } } You can switch hashes or arrays objects or lists or regular expressions or and booleans and more.
Feb 25 2003
"Kublai Kahn" <Kublai_member pathlink.com> wrote in message news:b3h655$1ng7$1 digitaldaemon.com...Perl 6 has a new switch statement called "given." In Perl 5 there was no switch statement because the designer of Perl wanted to create the right statement. The Perl 6 is denoted by given and the case is denoted by when. There is even syntax for exceptions. http://dev.perl.org/perl6/apocalypse/4 A typical Perl 6 "Switch" statement would be: given statement { when condition { } when condition { } } A typical Perl 6 Exception would be catch exception { when { } } You can switch hashes or arrays objects or lists or regular expressions orandbooleans and more.I don't know if this was a feature request for D or not, but here's my 2c. I think these longer forms of switch/catch statements would break C's conciseness which D tries to uphold. D already has these statements so I don't see the reasoning behind these. I don't see the point of having a boolean in a switch statement when it can just as easily be done with if/else. Although it may be an idea if switch statements could take in objects and return some result, parhaps by overloading the equals operator.
Mar 01 2003