[gambit-list] define-macro bug?

Christian Jaeger christian at pflanze.mine.nu
Fri Apr 27 05:43:43 EDT 2007

The problem is in the usage of internal defines: the definition of v
refers to m:

(define (solve-confs-248)
(let ((n (number-between 1 8))
(d (number-between 1 256))
(define m (expt (+ d 1) n))
(define v (if (> m n) m n))
(define t (+ n m v))
(assert (<= t 248))
(list n d m v t )

(You can see this when changing
;(define all-confs-248 (bag-of (solve-confs-248)))
(define (run)
(bag-of (solve-confs-248)))
and running run after loading.)

Internal defines are a mess. They don't behave the same as toplevel
defines, and this is, if I'm correct, because of the specification in R5Rs.


(So the funny part is that if you compile your file with Gambit, it
works, because the compiler is "more permmissive" as Marc puts it.)

Change your code to:

(define (solve-confs-248)
(let ((n (number-between 1 8))
(d (number-between 1 256)))
(let* ((m (expt (+ d 1) n))
(v (if (> m n) m n))
(t (+ n m v)))
(assert (<= t 248))
(list n d m v t ))))


More information about the Gambit-list mailing list