<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV>I'm trying to write an evaluator in the style of SICP that I hope will be at least somewhat idiomatic. What I have looks like this</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>;some global definitions (never modified)</DIV><DIV>(define evaluator-name "Strict Evaluator")</DIV><DIV>(define evaluator-version "0.0.1")</DIV><DIV>(define main-prompt ">>")</DIV><DIV>(define exit-message "Goodbye!")</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(define (eval-strict exp env) (raise-user-error 'oops))</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(define (run)</DIV><DIV> (let</DIV><DIV> ((env '())</DIV><DIV> (input-val (void)))</DIV><DIV> (printf "~a (version ~a)~n" evaluator-name evaluator-version)</DIV><DIV> (let</DIV><DIV> loop ()</DIV><DIV> (with-handlers</DIV><DIV> ((exn:fail:user? (lambda (exn) (printf "Error!~n") (loop))))</DIV><DIV> (printf "~a " main-prompt)</DIV><DIV> (set! input-val (read))</DIV><DIV> (if (not (eof-object? input-val))</DIV><DIV> (begin</DIV><DIV> (printf "~a~n~n" (eval-strict input-val env))</DIV><DIV> (loop))</DIV><DIV> (printf "~a~n" exit-message))))))</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>That code makes me uncomfortable for a couple of reasons</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>1. I don't want to break out of the loop when evaluating an expression like (/ 1 0) but instead report the error and then give the user an opportunity to enter another expression, leaving the environment intact. But, of course, I do want to break out of the loop in case of a programming error on my part, so my handler for exn:fail:user includes (loop) (where loop is the label in named let). I've never encountered code like this, and I wonder if it's even safe, much less idiomatic scheme.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>2. The second question involves the environment, which I anticipate storing as a list or perhaps a hash table. To me, it makes more sense for the evaluator to return an updated environment as a value than to have it modify a global value. But it also seems that this style could involve a lot of unnecessary copying. A third alternative I've considered is returning a list of updates that would then be sent on to a global environment object before proceeding (hmm...shadows of multithreaded scheme?) On the other hand, this approach sounds complex. I guess my question is whether I'm missing something obvious here. This all seems like it ought to be much more straightforward.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>Gregory Woodhouse</DIV><DIV><A href="mailto:gregory.woodhouse@sbcglobal.net">gregory.woodhouse@sbcglobal.net</A></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>"We may with advantage at times forget what we know."</DIV><DIV>--Publilius Cyrus, c. 100 B.C.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN></SPAN> </DIV><BR></BODY></HTML>