This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
defmacro: Null pointer exceptions with compiled files
- From: Adam Warner <lists at consulting dot net dot nz>
- To: Kawa Mailing List <kawa at sources dot redhat dot com>
- Date: Sun, 30 May 2004 13:37:04 +1200
- Subject: defmacro: Null pointer exceptions with compiled files
Hi Per and all,
Given this restriction discussed in the manual ...
"If you define a macro with defmacro, you (currently) cannot use the
macro in the same compilation as the definition. This restriction does
not apply to macros defined by define-syntax."
... I have put macros in individual files and compiled them as a
separate compilations. The macros do not work if I load the compiled
files instead of the .scm files.
For example, inc-and-dec.scm:
(defmacro inc (var)
`(begin
(set! ,var (+ ,var 1))
,var))
(defmacro dec (var)
`(begin
(set! ,var (- var 1))
,var))
$ kawa
#|kawa:1|# (compile-file "inc-and-dec.scm" "inc-and-dec")
#|kawa:2|# (load "inc-and-dec")
#|kawa:3|# (let ((i 1)) (inc i))
<stdin>:3:14: evaluating syntax transformer 'inc' threw java.lang.NullPointerException
#|kawa:4|# (load "inc-and-dec.scm")
#|kawa:5|# (let ((i 1)) (inc i))
2
Tested with the latest CVS version.
Regards,
Adam