Re: [Funk-devel] Queries and States in Funk - Design Review
Status: Planning
Brought to you by:
awgh
|
From: Ben K. <bk...@al...> - 2007-09-28 16:19:16
|
Awesome! Thank you, I've been trying to work that out for a while!
- b
On 9/28/07, felix winkelmann <bun...@gm...> wrote:
>
> On 9/27/07, Ben Kurtz <bk...@al...> wrote:
> >
> > The issue isn't with "include" itself. The problem is how to include
> eggs
> > with source that will work from the interpreter or compiled.
> >
> > Of use/require/require-extension, I haven't found a method of using an
> egg
> > that will work compiled and interpreted without changing code. The file
> > demo1.scm is an example of my workaround for compilation.
> >
>
> The usual approach is to split an egg into two parts: a compile-time
> part (installed in a .setup script, with a "(syntax)" property) and a
> run-time part (setup: "(require-at-runtime ...)" property). Doing a
> "require-extension" will load the compile-time part in both the
> interpreter and the compiler and you can here differentiate between
> the two cases via "(cond-expand (compiling ...) (else ...))".
> It sounds somewhat complicated but really isn't.
>
> Here a simple example:
>
> % cat foo.scm
> (cond-expand
> (compiling (print "compiled foo."))
> (else (print "interpreted foo.")))
> % cat foo-base.scm
> (print "foo base is executing.")
> % cat foo.setup
> (compile -s foo-base.scm)
> (install-extension
> 'foo
> '("foo.scm" "foo-base.so")
> '((syntax)
> (require-at-runtime foo-base)))
> % cat x.scm
> (require-extension foo)
> % chicken-setup foo
> /home/fwinkel/bin/csc -feature compiling-extension -s foo-base.scm
> cp -r foo.scm /home/fwinkel/lib/chicken/3/foo.scm
> chmod a+r /home/fwinkel/lib/chicken/3/foo.scm
> rm -fr /home/fwinkel/lib/chicken/3/foo-base.so
> cp -r foo-base.so /home/fwinkel/lib/chicken/3/foo-base.so
> chmod a+r /home/fwinkel/lib/chicken/3/foo-base.so
> chmod a+r /home/fwinkel/lib/chicken/3/foo.setup-info
> % csi -R foo -nqb
> interpreted foo.
> foo base is executing.
> % csc x.scm
> compiled foo.
> % x
> foo base is executing.
>
>
> cheers,
> felix
>
>
|