in reply to Re^3: How to Do Multiple OR in For Loops
in thread How to Do Multiple OR in For Loops

If a short circuit effect is wanted, it should be done explicitly.
That appears to be saying "if you want the short circuit effects of || and &&, you shouldn't use || and &&, but do it explicitly, but it's ok to use || and && (and get the short circuiting) if you don't want it".

But that would be strange, and it's probably not what you wanted to communicate.

Personally, I very much prefer to write things like:

if (ref $code && $code->()) {...} # short circuit
instead of
if (ref $code) { if ($code->()) { # explicitly ... } }
It's a long time since I coded Pascal, and I don't miss much of it. Actually, I don't think I miss anything from it.

Replies are listed 'Best First'.
Re^5: How to Do Multiple OR in For Loops
by LanX (Saint) on Apr 13, 2011 at 12:48 UTC
    > That appears to be saying "if you want the short circuit effects ...

    > it's probably not what you wanted to communicate.

    Sorry my fault!

    I meant if side effects are wanted they shouldn't be limited to elements till short circuit.

    e.g. if you want auto-vivication do it for all of them.

    Corrected in the -2 post.

    Cheers Rolf