Operator Precedence Considered Harmful

OperatorPrecedenceConsideredHarmful at Cunningham & Cunningham, Inc:

Almost every ProgrammingLanguage supporting InfixNotation for expressions has extensive OperatorPrecedence levels. This outgrowth of the mathematical origins of programming languages has been the cause of countless bugs. The problem with operator precedence is that it’s yet another thing a programmer has to memorize about the language he’s using. And since the precedence levels for each operator vary from one language to another, it’s easy to see why this can cause so much problems.

Of course, this has never bitten me… *cough* But, “accidentally” creating a simple scripting language without operator precedence for Audiality 2, I realized I didn’t miss it one bit! In fact, having strict left-to-right evaluation just makes code easier to read and write, because the code simply does exactly what it says. No implicit behavior. Parentheses are the only way things can deviate from the left-to-right rule, and that’s pretty clear and obvious.

So, now I’m going to do something drastic:

As of 0.3.7, I’m removing operator precedence from EEL!

As a temporary hack in 0.3.7, I’ll have the compiler issue warnings whenever an expression would have been evaluated differently with operator precedence enabled. I’ll probably also add a temporary directive ‘noprecedence’ to disable this warning for modules that have been updated, so we can rely on warnings to ensure that all scripts have been updated.

See also the issue on GitHub.


About Olofson

Founder of Olofson Arcade.
This entry was posted in Development, News. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>