Fw: Macro Question

Bent Phillipsen <[email protected]>
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <CAD1yAUR3qwiVWUUgyfyMP6P9z2YD_6ZfYuHOB9OzjWD0nNwcjg@mail.gmail.com>
Hello Joe!

IMO this is expected behavior - but doesn't work, as the variable in let
will be generated:

-----------------------------------------------------------------------------------------

(define-syntax bad-macro
        (syntax-rules ()
                ((_ val body) (let ((i val)) body))))

(bad-macro 5 (* 2 i))  ;does not work - "i" in let will be a newly
generated variable


(define-syntax good-macro
        (syntax-rules ()
                ((_ i val body) (let ((i val)) body))))

(good-macro i 5 (* 2 i))  ;does work

-----------------------------------------------------------------------------------------


So you probably need:

(module mm)

(define-class foo a)

(define-syntax darn
   (syntax-rules ()
      ((_ a )
       (let ((v 1))
          (instantiate::foo (a v))))))

(print (darn a))

... which compiles and gives the output:

#|foo [a: 1]|


Best regards

Bent
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.