[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Runtime syntax-case macros
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] Runtime syntax-case macros |
Date: |
Mon, 3 Sep 2007 20:53:10 +0200 |
On 9/3/07, address@hidden <address@hidden> wrote:
> Hello,
>
> I have a bunch of syntax-case macros that should be available at runtime,
> so that eval is able to use them. I'm compiling statically. What is the
> simplest way to achieve this?
You first have to create a statically linkable version of the
syntax-case extension,
by compiling the file syntax-case.scm (in a directory containing the extracted
egg files and after running chicken-setup -n to generate a required include
file) like this:
csc -c -O2 -d0 -unit syntax-case syntax-case.scm
This will generate an .o file that you can link with your application.
Add "(declare (uses syntax-case))" to your application and compile it
(don't forget to add syntax-case.o when linking - just pass it to csc).
Then have syntax-case-chicken-macros.scm in the same directory when
executing your program. Your own macros can be either loaded from a file
("load"), evaluated explicitly ("(eval '(define-syntax ...))") or loaded from
a compiled-in string:
(load (open-input-string #<<EOF
(define-syntax ...
EOF
) )
It is possible to get real compiled macro-expanders, but the only method I
have found so far involves rather hasty hacks. So if you can live with this,
you should be fine.
(if you don't need the macros in syntax-case-chicken-macros.scm, add
"-prelude '(register-feature! #:standard-syntax)'" when compiing
syntax-case.scm)
cheers,
felix