Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to make the academic argument, then of course it's not technically necessary to assign a variable more than once. The proof is that all code can be represented in <a href="http://en.wikipedia.org/wiki/Static_single_assignment_form" rel="noreferrer">SSA (Single Static Assignment)</a> form. Indeed, that's the most useful form for many kinds of static and dynamic analysis.</p> <p>At the same time, there are reasons we don't all write code in SSA form to begin with:</p> <ol> <li>It usually takes more statements (or more lines of code) to write code this way. Brevity has value.</li> <li>It's almost always less efficient. Yes I know you're talking about higher languages -- a fair scoping -- but even in the world of Java and C#, far away from assembly, speed matters. There are few applications where speed is irrelevant.</li> <li>It's not as easy to understand. Although SSA is "simpler" in a mathematical sense, it's more abstract from common sense, which is what matters in real-world programming. If you have to be really smart to grok it, then it has no place in programming at large.</li> </ol> <p>Even in your examples above, it's easy to poke holes. Take your <code>case</code> statement. What if there's an administrative option that determines whether <code>'*'</code> is allowed, and a separate one for whether <code>'?'</code> is allowed? Also, zero is not allowed for the integer case, unless the user has a system permission that allows it.</p> <p>This is a more real-world example with branches and conditions. Could you write this as a single "statement?" If so, is your "statement" really different from many separate statements? If not, how many temporary write-only variables do you need? And is that situation significantly better than just having a single variable?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload