|
From: | Daniel Leslie |
Subject: | Re: [Chicken-users] Macros and loading compiled code |
Date: | Wed, 10 Sep 2014 07:05:43 -0700 |
Try wrapping a module around the code to be compiled separately.On Wed, 10 Sep 2014 00:01:54 -0700
alex <address@hidden> wrote:
> Hi,
>
> I defined a macro. I compiled it separately and built it into my main
> program. When my main program calls the load procedure on normal
> Scheme source files, the procedures in these files use the macro
> without complaint.
>
> However, when it loads the dynamic object code created from compiling
> those same source files, I get an error about an "unbound value" in a
> subexpression of a macro _expression_. This seems to be because the
> macro expressions are being evaluated as normal procedure
> applications. If I insert the macro definition verbatim into each
> source file before I compile it, the errors do not occur.
>
> I tried passing both the source file and the macro definition file as
> input to the compiler. The errors remain.
> What else can I do to ensure that the dynamic object code knows about
> the macro definition?
>
> --Alex
>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-users
Compile it using the '-j <module-name>' flag then compile the generated
scheme file: <module-name>.import.scm
$ cat test.scm
(module test
*
(import chicken scheme)
(define-syntax a-macro
(syntax-rules ()
((_ l r) (+ l r))))
(define (a-function l r)
(+ l r))
)
compile like so:
$ csc -s test.scm -j test
$ csc -s test.import.scm
use it like so:
$ csi
#;1> (load "test.so")
#;2> (import test)
#;3> (a-function 1 2)
3
#;4> (a-macro 1 2)
3
I hope this is useful to you,
greetings,
Richard
_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users
[Prev in Thread] | Current Thread | [Next in Thread] |