in reply to Re^33: Why is the execution order of subexpressions undefined? (magic ruts)
in thread Why is the execution order of subexpressions undefined?

Replace + with ||, and * with &&.

Still ludicrous?

  • Comment on Re^34: Why is the execution order of subexpressions undefined? (magic ruts)

Replies are listed 'Best First'.
Re^35: Why is the execution order of subexpressions undefined? (magic ruts)
by BrowserUk (Patriarch) on Apr 19, 2005 at 14:04 UTC

    No. Logical operators short circuit, but you do not do associative and communicative math with logical operators.


    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?
      That's not my point. My point is that there are already operators where EXPR1 OP EXPR2 may cause one of the expression to not be evaluation, and people don't find that strange. Or inconvenient.

      And in languages with lazy evaluation, this is common.

        Hmm. I though lazy evaluation meant that the value wasn't calculated until needed.

        If f() is a lazy evaluating function and I call it, it will give a result. The only way it wouldn't get called in the statement

        result = f(a) * g(b) + h(c);

        is if the compiler took it upon itself to override my explicit request to call it. If perl ever starts doing that, I'm gonna use VB!


        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?