digitalmars.D - Perl's if and unless
- Brian Hammond (25/25) May 21 2004 I've never really liked Perl's general appearance except for its alterna...
- Juan C (4/6) May 21 2004
- Stephen Waits (5/17) May 21 2004 I have to say that this is one of the ugliest constructs I've ever
-
Walter
(4/6)
May 21 2004
That just seems backwards to me
. I like things to execute forwards, ... - Brian Hammond (2/7) May 21 2004 Well she's your baby so that's that :-)
- Phill (6/13) May 22 2004 not
I've never really liked Perl's general appearance except for its alternate if and unless constructs. These have the structure: <statement> if <condition>; <statement> unless <condition>; e.g. print "INFO: this is a message\n" if $verbose && $debug_level >= DBG_INFO; process_input() unless length $input == 0; The alternate if construct is equivalent to the D: if (<condition>) { <statement>; } The alternate unless construct is equivalent to the D: if (! <condition>) { <statement>; } I really like the unless because it reads so well. "do this unless this is true" I would think this bit of syntactic sugar wouldn't be too hard to add to D since it's just a simple transformation. I apologize if this has been requested and debated already. Brian
May 21 2004
<snip><statement> if <condition>; <statement> unless <condition>;</snip> Always makes me think of a bomb squad technician in a comedy: "Now cut the blue wire... <pause> but before you do that..."
May 21 2004
Juan C wrote:<snip>I have to say that this is one of the ugliest constructs I've ever faced. :) --Steve [glad to say that my perl hacking days are mostly behind me..]<statement> if <condition>; <statement> unless <condition>;</snip> Always makes me think of a bomb squad technician in a comedy: "Now cut the blue wire... <pause> but before you do that..."
May 21 2004
"Brian Hammond" <d at brianhammond dot comBrian_member pathlink.com> wrote in message news:c8lmu2$vdm$1 digitaldaemon.com...I really like the unless because it reads so well. "do this unless this is true"That just seems backwards to me <g>. I like things to execute forwards, not backwards.
May 21 2004
Well she's your baby so that's that :-) BrianI really like the unless because it reads so well. "do this unless this is true"That just seems backwards to me <g>. I like things to execute forwards, not backwards.
May 21 2004
"Brian Hammond" <d at brianhammond dot comBrian_member pathlink.com> wrote in message news:c8mh1p$264r$1 digitaldaemon.com...notI really like the unless because it reads so well. "do this unless this is true"That just seems backwards to me <g>. I like things to execute forwards,Thank god for that. It seems a bit strange to me as well. I dont like using a do / while either. Phillbackwards.Well she's your baby so that's that :-)
May 22 2004