Page Numbers: Yes X: 306 Y: 1.0" First Page: 30
Margins: Top: 1.0" Bottom: 1.3"
Heading:
CS-370 (FALL 1982)3-LISP REFERENCE MANUALNovember 1, 1982
————————————————————————————————————————————
8.a. The Reflective Processor (Modified for Transforms)
————————————————————————————————————————————
READ-NORMALISE-PRINT:
(define READ-NORMALISE-PRINT
(lambda simple [level env trans stream]
(block (prompt level)
(map (lambda simple [form!] (reply form! stream))
((trans normalise) (read stream) env trans id*))
((trans read-normalise-print) level env trans stream))))
———————————————
NORMALISE, REDUCE, and NORMALISE-RAIL:
(define NORMALISE
(lambda simple [exp env trans cont]
(cond [(normal exp) ((trans cont) exp)]
[(atom exp) ((trans cont) (binding exp env))]
[(rail exp) ((trans normalise-rail) exp env trans cont)]
[(pair exp) ((trans reduce) (car exp) (cdr exp) env trans cont)])))
(define REDUCE
(lambda simple [proc args env cont trans]
((trans normalise) proc env
(lambda simple [proc!]; Continuation C-PROC!
(if (reflective proc!)
(↑(de-reflect proc!) args env cont)
((trans normalise) args env
(lambda simple [args!]; Continuation C-ARGS!
(if (primitive proc!)
((trans cont) ↑(↑proc! . ↑args!))
((trans normalise) (body proc!)
(bind (pattern proc!) args! ↑(cenv proc!))
cont)))))))))
(define NORMALISE-RAIL
(lambda simple [rail env cont trans]
(if (empty rail)
((trans cont) (rcons))
((trans normalise) (1st rail) env
(lambda simple [first!]; Continuation C-FIRST!
((trans normalise-rail) (rest rail) env
(lambda simple [rest!]; Continuation C-REST!
((trans cont) (prep first! rest!)))))))))