[gambit-list] Possible bug in define-macro

William James w_a_x_man at yahoo.com
Sat Apr 9 15:30:43 EDT 2011


Gambit v4.6.1

> (include "~/srfi-1-reference.scm")
> (member 2 (iota 5) =)
(2 3 4)
> (define-macro (pushnew item lst . test)
  (let ((== (gensym)))
    `(let ((,==  ,(if (null? test) equal? (car test))))
      (if (not (member ,item ,lst ,==))
        (set! ,lst (cons ,item ,lst))))))
>
(define flist '(2 3 5))
>
(pushnew 5 flist)
*** ERROR IN (console)@21.1 -- Ill-formed expression
>


This macro works properly in Guile (and Bigloo):

guile> (load "test-pushnew.scm")
(2.0 8 2 3 5)

where test-pushnew.scm is

(define-macro (pushnew item lst . test)
  (let ((== (gensym)))
    `(let ((,==  ,(if (null? test) equal? (car test))))
      (if (not (member ,item ,lst ,==))
        (set! ,lst (cons ,item ,lst))))))

(define flist '(2 3 5))

(pushnew 5 flist)

(pushnew 8 flist)

(pushnew 2.0 flist)

(pushnew 3.0 flist =)

(write flist) (newline)




More information about the Gambit-list mailing list