This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]