Parse, don’t type-check
&gt; The essential message is to make illegal states unrepresentable.<p>That&#x27;s why, in C we have:<p><pre><code>    if (a = b)
</code></pre>
and:<p><pre><code>    if (a &lt; b &lt; c)
</code></pre>
that cause (in some compilers) warnings. I wanted to make this an error in D. One option is to check for and disallow them after the parse, but that left:<p><pre><code>    if ((a &lt; b) &lt; c)
</code></pre>
as still an error. I wanted to allow these constructs to remain if they were parenthesized, as that would imply they were deliberate. (Yes, parenthesized expressions could be a separate grammar, but I thought that was an awful idea.)<p>The solution is to fix the grammar, so they wouldn&#x27;t even parse. The beauty of this is one doesn&#x27;t have to enable warnings, or have a separate check for them, it just won&#x27;t compile. Even better, D&#x27;s expression grammar is the same as C&#x27;s, and it did not upset anything else in the grammar as a side effect.<p>Based on my experience at Boeing designing hardware, defining the problem out of existence is a great way to design robust systems.