Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Useless unless

by tilly (Archbishop)
on Aug 08, 2005 at 05:00 UTC ( [id://481789]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Useless unless
in thread Useless unless

What happens if doX returns a false value?

Replies are listed 'Best First'.
Re^4: Useless unless
by sk (Curate) on Aug 08, 2005 at 06:07 UTC
    I think BrowserUk's point was on functions that don't return a value. I was assuming that in my post o/w I need to use the ternerary operator to catch it. Well one might argue that it is not always required to trap the return value but I feel if the funcion returns something then it is worth something

    I still like the otherwise idea coz it makes the code more english like. Nothing more, nothing less. :) I cannot argue with BrowserUk on the equivalence of the code! :)They do the same thing!

      In Perl, all functions return a value unless normal processing is interrupted. The latter would include functions that die or exit.
        Thanks for the correction tilly! I should have known better. Agreed all functions return a value unless called in a void context!!!

        When i started to play around with BrowserUk's statement on functions that return a value (with explicit return in my case) I realized i did not have that in mind when i wrote for the otherwise idea... So did not reply back saying it will fail under that instance coz i am not using the return value either in my code. What i forgot in the process was that subs implicitly return the last expression evaluated and the problem of returning false will execute both functions even if an explicit return in not used

        I guess after reading jdporter's post and your question about functions returning false values, I guess it makes me feel otherwise will be a good feature if one want to write such conditional statements

        I know it is too late in the game to think about such additions but it is nice to discuss!

        -SK

Re^4: Useless unless
by BrowserUk (Patriarch) on Aug 08, 2005 at 06:34 UTC

    Obviously, if there was any chance of that it would have to be

    $cond and doX,1 or doY;

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found