On Monday, 24 March 2014 at 03:55:41 UTC, bearophile wrote:
Can D help the programmer reduce the frequency of similar bugs? And do we want to?

When doing math, I always use parentheses and casts to force a single possible outcome of the result, regardless of the order of evaluation and auto-casting. I also always write all my case/break statements as a set of matching pairs before writing any code in a switch, so the idea that something would fall through on accident seems like something that could never happen.

People should have habits like these (and putting constant values on the left side of a comparison), but I suspect that most people would be annoyed at being forced to do it by the compiler, even though if they were aware that this was a "good habit", they'd all start doing it and life would be perfect.

Reply via email to