Awesome!  Thank you, I've been trying to work that out for a while!

- b

On 9/28/07, felix winkelmann <> wrote:
On 9/27/07, Ben Kurtz <> 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
(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)
'("foo.scm" "")
   (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-
  cp -r /home/fwinkel/lib/chicken/3/
  chmod a+r /home/fwinkel/lib/chicken/3/
  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.