Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Ternary Quizical behaviour?

by perlfan (Priest)
on Jul 10, 2020 at 20:35 UTC ( #11119160=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2020-09-21 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (127 votes). Check out past polls.

    Notices?