Hello, I understand syntax-rules and Common Lisp's defmacro, but I'm still getting acquainted with Chicken's implementation of explicitly renaming macros. So far I have had success in writing simple macros, but there's one thing I don't understand.
This program seems to work fine when loaded from csi, but csc complains that a procedure used inside the renaming procedure is unbound (even though it was defined shortly before the macro definition): /--- ;; macro.scm (a silly artificial example) ;; swaps the two first elements of a list (define change-sexp (lambda (sexp) (append (list (cadr sexp) (car sexp)) (cddr sexp)))) ;; swaps the two first arguments of a procedure call (define-syntax swap-args (lambda (expr ren cmp) `(,(caadr expr) ,@(change-sexp (cdadr expr))))) (display (expand '(swap-args (/ 1 2 3)))) (newline) (display (swap-args (/ 1 2 3))) (newline) \--- $ csi -q #;1> (load "macro.scm") ; loading macro.scm ... (/ 2 1 3) 0.666666666666667 #;2> $ csc macro.scm Error: during expansion of (swap-args ...) - unbound variable: change-sexp Call history: <syntax> (##core#begin (display (swap-args (/ 1 2 3)))) <syntax> (display (swap-args (/ 1 2 3))) <syntax> (swap-args (/ 1 2 3)) <eval> (##sys#cons (caadr expr) (##sys#append (change-sexp (cdadr expr)) (##core#quote ()))) <eval> (caadr expr) <eval> (##sys#append (change-sexp (cdadr expr)) (##core#quote ())) <eval> (change-sexp (cdadr expr)) <-- Error: shell command terminated with non-zero exit status 17920: /usr/local/bin/chicken macro.scm -output-file macro.c Is it not possible to use auxiliary procedures when defining renaming macros in compiled code? Thanks, J. _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users