[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Giving (load)ed files access to macros?
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] Giving (load)ed files access to macros? |
Date: |
Tue, 6 Jun 2006 16:06:31 +0200 |
On 6/5/06, Alejandro Forero Cuervo <address@hidden> wrote:
> To define macros that are available at run-time (which seems to be what
> you are trying to do), you can put a "(declare (run-time-macros))" in your
> (compiled) code. This will make all low-level macros defined with
> define-macro available in code eval'd at run-time.
> If you need the non-standard syntax-extensions, you can do either:
> declare run-time-macros and add "(include "chicken-more-macros")",
> which compiles all macros in (makes your code bigger)
Hmm, this doesn't seem to work. :-/ I have a file test.scm with the
following code:
(declare (run-time-macros))
(load "foo.scm")
In foo.scm I have this:
(receive (a) #f a)
However, I get:
$ csi -script test.scm # does work
Warning: declarations are ignored in interpreted code
(##core#declare (quote (run-time-macros)))
$ csc test.scm
$ ./test
Error: unbound variable: a
You should add
(include "chicken-more-macros")
in your compiled file to make them available. Csi already has them
compiled in.
On the other hand, using (eval '(require-extension
chicken-more-macros)) seems to work slightly better but still not
satisfactorily: I can't make my extensions load macros from extensions
that have already been loaded by the compiled code.
For example, I have:
test.scm:
(require-extension srfi-40)
(eval '(require-extension chicken-more-macros))
(load "foo.scm")
foo.scm:
(require-extension srfi-40)
(stream-cons #f stream-null))
If I run the compiled test program I get:
Error: unbound variable: stream-cons
How can my extensions use macros defined in Chicken eggs that are used
by the compiled code?
The macros are loaded at compile-time, when compiling. The
"require-extension" in foo.scm on the other hand should work.
Have you removed the (register-feature! 'srfi-40) from the srfi-40
egg (see previous mail)?
(felix)