title: Lazy logic and temporary values to improve the reading of an expression
body: <p>Sorry for the poor explanatory title, I'm not able to find a better one (yet).</p>
  
  <p>I'm used to code boolean expressions adding some temporary variables to improve the reading of an expression, in other words I dislike this:</p>
  
  <pre><code>// Example 1
  // hard to read and understand at first glance
  if (value % 2 &amp;&amp; value ^ weirdFlags &amp;&amp;
      (value &gt; threshold) &amp;&amp; (value &lt; ceiling) &amp;&amp;
      /* lots of comparisions */)
  { /* do something*/ }
  </code></pre>
  
  <p>And prefer this:</p>
  
  <pre><code>// Example 2
  // this is way easier to read and understand
  const bool isEven = value % 2;
  const bool flagsChecked = value ^ weirdFlags;
  const bool inRange = (value &gt; threshold) &amp;&amp; (value &lt; ceiling);
  const bool foo = /* lots of comparisions */;
  if (isEven &amp;&amp; flagsChecked &amp;&amp; inRange &amp;&amp; foo)
  { /* do something*/ }
  </code></pre>
  
  <p>But using my favorite coding style, I'm not taking advantage of the lazy logic optimizations because all the temporary values are computed, while with the other coding style only the imprescindible is computed.</p>
  
  <p>There's another solution, that grants the use of the lazy logic optimizations and keeps the code readable, that is comment the code:</p>
  
  <pre><code>// Example 3
  // this check test if the value is an even number
  // and checks the value with the provided flags
  // and assures that the value is in the required range
  // and lots of additional comparisions
  if (value % 2 &amp;&amp; value ^ weirdFlags &amp;&amp;
      (value &gt; threshold) &amp;&amp; (value &lt; ceiling) &amp;&amp;
      /* lots of comparisions */)
  { /* do something*/ }
  </code></pre>
  
  <p>But there's no warranties about the code comments matches the code below during the code development while a team of programmers are coding day by day the same source file (not all the coders care about the good documentation). That's why I preffer that the code explains itself in a neat way.</p>
  
  <p>So, finally, studying the  Example 2 case, that declares temporary values as <code>const</code>, only use them in the boolean expression, in the same scope of the expression and close to the expression itself, the questions are:</p>
  
  <ul>
  <li>In the Example 2, will the compiler perform some kind of optimizations involving the temporary values in order to improve the performance of the boolean expression (lazy evaluation)?</li>
  <li>In your own opinion, which of the three examples is the most correct? why?</li>
  </ul>
  
  <p>Thanks for the advice.</p>