4.2 Exercise 4.2

define is a special form, but it is syntactically identical to a function application. If Louis makes eval check whether the form matches that of a function application before assignments, it will treat assignments as calls to a function named define, which is not the correct behavior.

If, as suggested, we change the language so that all function applications are denoted by a list whose first element is the symbol call, followed by the function name and all the arguments, we would have to rewrite the detection for function application as follows:

(define (application? exp) (tagged-list? exp 'call))
(define (operator exp) (cadr exp))
(define (operands exp) (cddr exp))

And then eval would look more like this:

(define (eval exp env)
  (cond ((self-evaluating? exp) exp)
        ((variable? exp) (lookup-variable-value exp env))
        ((quoted? exp) (text-of-quotation exp))
        ((application? exp)
         (apply (eval (operator exp) env)
                (list-of-values (operands exp) env)))
        ((assignment? exp) (eval-assignment exp env))
        ((definition? exp) (eval-definition exp env))
        ((if? exp) (eval-if exp env))
        ((lambda? exp)
         (make-procedure (lambda-parameters exp)
                         (lambda-body exp)
                         env))
        ((begin? exp)
         (eval-sequence (begin-actions exp) e nv))
        ((cond? exp) (eval (cond->if exp) env))
        (else
         (error "Unknown expression type -- EVAL" exp))))