I'm currently working on a set of utilities, written in Chicken Scheme, and this is the first time I've tried writing a multi-file based program (or set of programs) in Chicken Scheme, and I'm having some trouble figuring out how to utilize code defined in accessory files correctly so that when you compile everything, the code defined in file A
will be accessible to the compiled form of file B
. I essentially need Chicken Scheme's equivalent to the following C code:
#include "my_helper_lib.h"
int
main(void)
{
/* use definitions provided by my_helper_lib.h */
return 0;
}
I've tried using all of the following, but they all produced sundry and unusual errors, errors like: '()
being undefined, which doesn't make sense, since '()
is just another way of writing (list)
.
;;; using `use`
(use "helper.scm") ;; Error: (require) cannot load extension: helper.scm
;;; using modules
;; helper.scm
(module helper (foo)
(import scheme)
(define foo (and (display "foobar") (newline))))
;; main.scm
(import helper) ;; Error: module unresolved: helper
;;; using `load`
(load helper.scm) ;; Error: unbound variable: helper.scm
(load "helper.scm") ;; Error: unbound variable: use
;; note: helper.scm contained `(use scheme)` at this point
;; using `require`
(require 'helper.scm) ;; Error: (require) cannot load extension: helper.scm