http://qs321.pair.com?node_id=11119160


in reply to Re: Ternary Quizical behaviour?
in thread Ternary Quizical behaviour?

I don't think that autovivification is an issue if you're consistent. But I see now.

>Question: the if-statement is safe as (I guess) it evaluates each sub-conditional to a true-false and does not stack the variables?

I have not tried it, but I assume that works as intended. It's just really surprising to see (in terms of the principle of lease surprise) and relies on an esoteric understanding of variable scoping (and a sharp eye). One drawback I can see is if you're relying on that honking mess being fully evaluated. Due to the short circuiting of conditions it's likely that if you treat this as a reasonable idiom that you'll run into some really freaking hard-to-debug issues caused by unexpected side effects - in otherwords, you're tying the state of a variable to external input via a potentially complex logic statement that could possibly not be evaluated fully due to said extern input. So if I were you (and I may be...<__<) I would break this habit. It's certainly not worse that autovivification, not worth the potential maintenance cost, and .. wait ...it is WAY worse than autovivification =D. HTH.