Re:Show HN: “Crafting Interpreters” chapter, control flow an...
by pacaro on Tuesday June 27, 2017 @12:34AM
(#14642604)
Granted, the intersection of precedence and associativity is a great source of confusion (and any number of annoying Facebook memes)
I'm not a formally trained mathematician, but one way to rationalize + and - having the same precedence, is to consider them as inverses of each other, so your two examples can be written as
a + -b + c
And
a + b + -c
At which point precedence and associativity no longer matter. The same can be done with multiplication and division
I'm not a formally trained mathematician, but one way to rationalize + and - having the same precedence, is to consider them as inverses of each other, so your two examples can be written as
a + -b + c
And
a + b + -c
At which point precedence and associativity no longer matter. The same can be done with multiplication and division