4 ms·
> If dealing with a function, the evaluation will always be arguments from left to right are evaluated first, and then the function is called with the result of
by pg314 9y ago
> If dealing with a function, the evaluation will always be arguments from left to right are evaluated first, and then the function is called with the result of evaluating the args.
The order of evaluation depends on the dialect. Common Lisp evaluates the arguments from left to right, but e.g. in Scheme the order of evaluation is deliberately left unspecified.
- didibus 9y agoIn the spec, but I've yet to see an implementation that does not follow left to right order. Do you know of any ?
- pg314 9y agoExercise 4.1 in SICP [1] asks for an implementation that evaluates operands from right to left. :) Other than that, I don't know of any implementations that do. I also don't know of any implementations that guarantee left to right order. Many manuals specifically mention not to rely on the order of evaluation (e.g. Chez Scheme). Since I try to avoid depending on unspecified behavior if I can avoid it, I might not notice when an implementation uses a different evaluation order. I would expect one of the optimising compilers (MIT Scheme, Chez Scheme, Stalin) to be your best bet to find a real implementation with non-left-to-right order. And it might require a specific set of circumstances to trigger, so trivial examples might work ok. And of course, just because current implementations use left to right order, doesn't mean that that can't change in the future. [1] https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html#%_sec_4.1 https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.htm...