On the subject of associativity when all operators have equal precendence, Ken Iverson writes in Conventions Governing Order of Evaluation that
The reasons for choosing a right-to-left instead of a left-to-right convention are:
- The usual mathematical convention of placing a monadic function to the left of its argument leads to a right-to-left execution for monadic functions; for example,
F G x ≡ F (G x)
.- The notation
F/z
for reduction (by any dyadic functionF
) tends to require fewer parentheses with a right-to-left convention. For example, expressions such as+/(x×y)
or+/(u/x)
tend to occur more frequently than(+/x)×y
and(+/u)/x
.- An expression evaluated from right to left is the easiest to read from left to right. For example, the expression
a+x×b+x×c+x×d+x×e+x×f(for the efficient evaluation of a polynomial) is read as a plus the entire expression following, or as a plus x times the following expression, or as a plus x times b plus the following expression, and so on.- In the definition
F/x ≡ x1 F x2 F x3 F ... F x⍴xthe right-to-left convention leads to a more useful definition for nonassociative functions F than does the left-to-right convention. For example,-/x
denotes the alternating sum of the components ofx
, whereas in a left-to-right convention it would denote the first component minus the sum of the remaining components. Thus if d is the vector of decimal digits representing the numbern
, then the value of the expression0=9|+/d
determines the divisibility ofn
by9
; in the right-to-left convention, the similar expression0=11|-/d
determines divisibility by11
.
What would be the reasons for choosing a left-to-right convention?
1 + 2 * 3
is 9). Would an explanation of that be relevant here? $\endgroup$