sicp-ex-4.51



<< Previous exercise (4.50) | Index | Next exercise (4.52) >>


meteorgan

  
  
 ;; In analyze adds 
 ((pernamenant-set? expr) (analyze-pernamenant-set expr)) 
  
 ;; add those code.  
 (define (pernamenant-set? expr) (tagged-list? expr 'pernamenant-set!)) 
  
 (define (analyze-pernamenant-set expr) 
   (let ((var (assignment-variable expr)) 
         (vproc (analyze (assignment-value expr)))) 
    (lambda (env succeed fail) 
     (vproc env 
            (lambda (val fail2) 
             (set-variable-value! var val env) 
             (succeed 'ok  fail2)) 
            fail)))) 
  
 if use set!, the result will be: 
 (a b 1) (a c 1) ...