[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: |
Andreas Rottmann |
Subject: |
Re: Problem with define-macro from compiled file (Guile 1.9) |
Date: |
Sat, 08 Jan 2011 00:22:58 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Hans Aberg <address@hidden> writes:
> On 6 Jan 2011, at 19:18, Patrick Bernaud wrote:
>
>> I have a case where a macro is defined in a file that is then loaded
>> by another which makes use of the macro. And it produces a 'wrong type
>> to apply' error from the VM.
>>
>> (Works fine with GUILE_AUTO_COMPILE=0 and compiled files removed).
>>
>> For example, with the 'when' macro from the manual:
>>
>> -%<---- 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 ----%<-
>
> If you are writing your own macro, I find 'define-syntax' easier:
>
> [...]
It's not only easier, it also not inherently broken (as `define-macro'
is). See <http://en.wikipedia.org/wiki/Hygienic_macro> for a discussion
of the hygiene issue.
For example, the following invocation of `when' will break when
implemented with `define-macro' as above:
(let ((begin #f))
(when #t
(display "Launching missiles!\n")))
Regards, Rotty
--
Andreas Rottmann -- <http://rotty.yi.org/>