Include is an operation on source code (it includes the text of a file in the current one). A function call is an operation on scheme values.
So, it's going to be hard in scheme… (CL has ways to use macros at run-time I think) If you know your list, you can try something like
(define-macro (load-all-files . files) (if (null? files) #f `(begin (include ,(car files)) (load-all-files ,@(cdr files)))))
but you need to call it with the list of files in the source (that is, "(load-all-files f1 f2 f3)")
Another, dirtier way, I guess, would be to READ your files, append them to your quoted dynamic code, and to eval it all…
P!
2009/2/14 François Magnan francois.magnan@licef.ca
Hi fellow Gambitters,
I have a problem trying to dynamically load scheme files that contains macros. I know that when a file contains a macro, the macro definition must be in the same file as the macro usage. If not, one must use the (include ....) special form to import the macro definition.
I would like to be able to use (include ...) inside a function to programmatically include some files like (load ...) can do.
For example, if
(for-each (lambda (file) (include file)) '("file1" "file2" ...))
*** ERROR IN (console)@2.15 -- Filename expected
could work!
Is there any way to make this work without appending all the files together.
Thank you, Francois Magnan
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list