<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">I'm looking at some old Scheme code and find that the code still works under (#lang racket) but trace is unhappy with the use of set! in the traced function.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">set!: cannot modify a constant: next-leaf-generator</font><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> I also tried (#lang r5rs) but it's unhappy with my require.</div><div style="font-family: 'times new roman', 'new york', times,
serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">(require racket/trace) => <span class="Apple-style-span" style="font-size: medium; ">expand: unbound identifier in module in: require</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">What #lang/require must I use to work around this?<br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Michael</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">==========</div><div style="font-family: 'times new
roman', 'new york', times, serif; font-size: 12pt; "><br></div><div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">#lang racket</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">(require racket/trace)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">(define next-leaf-generator</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (λ (obj eot)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (letrec ((return #f)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york',
times, serif"> (cont (λ (x)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (recur obj)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (set! cont (λ (x) (return eot)))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (cont #f)))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (recur (λ (obj)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">
(if (pair? obj)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (for-each recur obj)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (call/cc (λ (c)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (set! cont c)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (return
obj)))))))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (λ () (call/cc (λ (ret)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (set! return ret)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (cont #f)))))))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">(define leaf-eq?</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (λ (x y)</font></div><div><font class="Apple-style-span" face="'times new roman',
'new york', times, serif"> (let* ((eot (list 'eot))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (xf (next-leaf-generator x eot))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (yf (next-leaf-generator y eot)))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (letrec ((loop (λ (x y)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (cond ((not (eq? x y)) #f)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">
((eq? eot x) #t)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (else (loop (xf) (yf)))))))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> (loop (xf) (yf))))))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">;> (leaf-eq? '(a (b (c))) '((a) b c))</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">;#t</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">;> (leaf-eq? '(a (b (c))) '((a) b c d))</font></div><div><font class="Apple-style-span" face="'times new roman',
'new york', times, serif">;#f</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">;> </font></div></div></div></body></html>