[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with define-macro from compiled file (Guile 1.9)
From: |
Ludovic Courtès |
Subject: |
Re: Problem with define-macro from compiled file (Guile 1.9) |
Date: |
Fri, 07 Jan 2011 00:58:46 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) |
Hi,
Patrick Bernaud <address@hidden> writes:
> -%<---- when.scm ----%<-
> (define-macro (when cond exp . rest)
> `(if ,cond
> (begin ,exp . ,rest)))
> -%<---- when.scm ----%<-
>
> -%<---- test.scm ----%<-
> (load "when.scm")
> (when #t (display "Launching missiles!\n"))
> -%<---- test.scm ----%<-
[...]
> ERROR: In procedure catch-closure:
> ERROR: Wrong type to apply: #<syntax-transformer when>
This is because ‘when’ wasn’t expanded in ‘test.scm’, because its
definition wasn’t visible at the time ‘test.scm’ was compiled (remember
that ‘load’ is something that happens at run time.)
Thus the compiler assumed that ‘when’ is a global variable, leading to
the error above (compiling ‘test.scm’ with ‘guile-tools compile
-Wunbound-variable’ should have given a warning.)
The solution is to get rid of ‘load’: either use ‘(include "when.scm")’,
or turn ‘when.scm’ into a module and use it in ‘test.scm’.
Thanks,
Ludo’.