Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Shouldn't operator precedence guarantee that b() is executed before a()? No. Operator precedence says what to do with values in an expression once you have its input values. Order of evaluation ...
Answer
#1: Initial revision
<blockquote>Shouldn't operator precedence guarantee that b() is executed before a()?</blockquote> No. Operator precedence says what to do with values in an expression once you have its input values. Order of evaluation is about how to get the values. The two can be different without any inconsistency. In your second example, the functions in the expression are evaluated in left to right order because of the compiler's <i>order of evaluation</i>. Those three results are then used to compute the expression value with multiplication first because of the compiler's <i>order of precedence<i>.