Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: A new idiom -or- I Hate Unless

by ambrus (Abbot)
on Aug 23, 2004 at 09:11 UTC ( [id://385029]=note: print w/replies, xml ) Need Help??


in reply to Re: A new idiom -or- I Hate Unless
in thread A new idiom -or- I Hate Unless

Anyway, I still think unless is still much nicer than its slang equivalent, !if .

I have no problem with unless, but I cringe when I see it used as the block form. I find it interesting to note that perlsyn doesn't even bother mentioning it, so I'm surprised that it pops up so often.

It is mentioned in perlsyn (5.8.2), it's just easy to miss it:

from perlsyn(1): The following compound statements may be used to control flow: if (EXPR) BLOCK if (EXPR) BLOCK else BLOCK if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK ... The "if" statement is straightforward. Because BLOCKs are alwa +ys bounded by curly brackets, there is never any ambiguity about which "if" an "els +e" goes with. If you use "unless" in place of "if", the sense of the test is rev +ersed.

Btw, why isn't there an elsunless statement like if : unless = while : until = elsif : elsunless?

(Update: fixed /code tag)

Replies are listed 'Best First'.
Re^3: A new idiom -or- I Hate Unless
by BrowserUk (Patriarch) on Aug 23, 2004 at 09:23 UTC
    Btw, why isn't there an elsunless statement like if : unless = while : until = elsif : elsunless?

    LW had something to say on that in a recent post on p6lang:

    .... And there's a new C<elsunless> in Perl 6--except that it's spelled C<elsif not>. C<:-)>

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://385029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found