Gauche is a Scheme interpreter, in the sense that it reads a Scheme form at a time and evaluates it. Actually, Gauche compiles every toplevel form into an intermediate form before executing.
Built-in syntaxes and macros are recognized and expanded at the compilation time. Some built-in procedures are expanded in-line as far as the compiler can see the global binding is not altered at the time the form is compiled.
This raises a few problems you should care.
load is a procedure in Gauche, therefore evaluated at run time.
If the loaded program defines a macro, which is available for the compiler
after the toplevel form containing
load is evaluated. So, suppose
foo.scm defines a macro
foo, and you use the macro
;; in “foo.scm” (define-syntax foo (syntax-rules () ((_ arg) (quote arg)))) ;; in your program (begin (load "foo") (foo (1 2 3))) ⇒ error, bad procedure: ‘1’ (load "foo") (foo (1 2 3)) ⇒ '(1 2 3)
(begin (load ...)) form fails, because the compiler
foo is a special form at the compilation time
(1 2 3) as if it is a normal procedure call.
The latter example works, however, since the execution
of the toplevel form
(load "foo") is done before
(foo (1 2 3)) is compiled.
To avoid this kind of subtleties, use
to load a program fragments. Those are recognized by the compiler.
On the other hand, since
use is recognized
by the compiler, the specified file is loaded even if the form
is in the conditional expression. If you really need to load
a file on certain condition, use
load or do dispatch in macro
cond-expand form (see Feature conditional).)