Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Ternary Quizical behaviour?

by perlfan (Vicar)
on Jul 10, 2020 at 20:35 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-04-24 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found