Discussion:
[Chicken-users] Like 'include', but different?
Mark Carter
2018-08-23 15:54:03 UTC
Permalink
I have code where I 'include' other files. Suppose I compile that file.
As part of execution, it will try to load those other files, which isn't
what I want.

Is there a way of telling chicken that during the interpretation or
compilation, the file should be loaded, but during execution, don't load
the files?

... a bit like loading a module, but without using modules.
Mark Carter
2018-08-23 17:59:27 UTC
Permalink
OK, I think I've figured it out.

In the calling code (calc.scm), I have to do something like:

(cond-expand
 (compiling (declare (uses calc-yy)))
 (else (load "calc-yy.scm")))

In compiling, I have to do:

csc -unit calc-yy -c calc-yy.scm

csc calc.scm calc-yy.o

That seem to work.
k***@upyum.com
2018-08-25 11:10:36 UTC
Permalink
Post by Mark Carter
I have code where I 'include' other files. Suppose I compile that file.
As part of execution, it will try to load those other files, which isn't
what I want.
Is there a way of telling chicken that during the interpretation or
compilation, the file should be loaded, but during execution, don't load
the files?
The `include` form should be what you need here. I don’t really understand
the problem you’re having. Could you post a little example of it?

Here is how (include "file.scm") should behave:
- when compiled, the include form will be rewritten with the content of the
specified file
- when interpreted, it will behave like (load "file.scm")

Loading...