in reply to Re: Short circuits in Logical AND (&&)
in thread Short circuits in Logical AND (&&)

Uh uh ... is that construction short-circuit?   Not sure that it is.   And if not, “not equivalent.”

Also, I do not like to write code that “assumes” what “just happens to be the case right now,” in such a way that it requires it and therefore breaks down when something causally unrelated to it (i.e. the assumption...) changes in what ought to be an inconsequential way.   That is the sort of coding that bites you in the punctuation-mark.   I’ve been bitten by it enough times, and have cleaned up after it enough times, to have come to really resent it.

Replies are listed 'Best First'.
Re^3: Short circuits in Logical AND (&&)
by JavaFan (Canon) on Aug 02, 2011 at 14:57 UTC
    Uh uh ... is that construction short-circuit? Not sure that it is. And if not, “not equivalent.”
    Rubbish.

    Short-circuiting and not short-circuiting are only non-equivalent if the second expression has side-effects. Since it's not mentioned the variables are tied, it's safe to assume there's not short-circuiting happening.

    So, under the stated assumptions (using 0 and 1), they are equivalent.

    Not that I would use a construct. I find using bit-twiddling operators to do boolean logic a misplaced cuteness that serves nothing. To me, it smells like the author is saying "look at me, I think I've surpassed the level of grasshopper".