When we defined the evaluation model in section
, we said that the first step in evaluating an expression is to evaluate its subexpressions. But we never specified the order in which the subexpressions should be evaluated (e.g., left to right or right to left). When we introduce assignment, the order in which the arguments to a procedure are evaluated can make a difference to the result. Define a simple procedure
such that evaluating
(+ (f 0) (f 1))
if the arguments to
are evaluated from left to right but will return
if the arguments are evaluated from right to left.
There are no comments yet.
You must log in to post a comment.Login
(define f (make-f)) (define left f) (check-equal? (+ (left 0) (left 1)) 0) (define right (make-f)) (check-equal? (+ (right 1) (right 0)) 1)