Closed AndrewTolmach closed 11 months ago
You make a compelling argument.
The main reason it was done that way was to avoid needing to later change the grammar, interpreters, etc. in Ch. 8 and beyond.
It's not clear to me that all the work of making those later changes would be worth it to avoid having a language feature that is slightly more general than it needs to be.
Why is $exp$ (other than
print(...)
) allowed as a form of $stmt$ in $\mathcal{L}_{int}$ and subsequent languages up through Ch.7? This seems to complicate the languages with no benefit. And since the results of these expressions are thrown away, these expressions cannot be tested (beyond testing that aninput_int()
expression evaluates; there are no other relevant side-effects until we get functions in Ch. 8.)