Fixing the Bug

left top right

Note: We change j-eval so that it never returns an answer. Instead, we pass it a third argument (its continuation) and it calls that when it has computed the answer.
(define (j-eval-block exp env next)
  (define (loop exprs)
    (if (null? exprs)
        (next "End of block")
        (j-eval (car exprs) env
                (lambda (val) (loop (cdr exprs))))))
  (loop (cdr exp)))

(define (j-eval-oops exp env next)
  ; Never calls NEXT!!!
  (let ((name (second exp)))
    (let ((label (find-label name)))
      (if label
          (label)
          (error "No handler for error" name)))))

Jim Miller W3C