Uniformity in Scheme syntax evaluation
I went ahead and made the continuation style evaluator more uniform in the handling of syntax expressions.
I also moved the recognition test for syntax expressions up into the body of ev-c. This makes evsyntax-c a procedure that handles only syntax expressions. The interpreter is much faster now. I attribute this to the still primitive CONSing of arguments in a procedure call. The vast majority of procedure calls are by name, and the redundant test bypasses the call to evsyntax-c. This removes two levels of internal interpreter calls for each interpreted procedure call. The new code adds a redundant lookup only for syntax expressions. The lookup was already redundant when interpretation of procedure calls involved evsyntax-c.
(syntax?
(lambda (exp env)
(eq? (first (bound-value (lookup (car exp) env))) prim-syntax-mark)))
(ev-c
(lambda (exp env c)
(cond
((constant? exp) (evconst-c exp env c))
((symbol? exp) (evvar-c exp env c))
((syntax? exp env) (evsyntax-c exp env c))
(#t (evcall-c exp env c)))))
(evsyntax-c
(lambda (exp env c)
(evsyntaxc-c (bound-value (lookup (car exp) env)) exp env c)))
(evsyntaxc-c
(lambda (cmddef exp env c)
(cond
((eq? (second cmddef) 'quote) (evquote-c exp env c))
((eq? (second cmddef) 'cond) (evcond-c exp env c))
((eq? (second cmddef) 'set!) (evset-c exp env c))
((eq? (second cmddef) 'letrec) (evletrec-c exp env c))
((eq? (second cmddef) 'lambda) (evlambda-c exp env c))
(#t (undefined-c exp env c)))))