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)