Re: What #,(foo) does tell... include vs. load
Marc Feeley 07 Oct 1999 21:14 UTC
> Provided that the following function is defined
> (define (read-all-as-a-begin-expr filename)
> (with-input-from-file filename
> (lambda ()
> (cons 'begin
> (let loop ((datum (read)))
> (if (eof-object? datum) '()
> (cons datum (loop (read)))))))))
>
> and an 'include' reader-ctor is set up as
> (define-reader-ctor 'include read-all-as-a-begin-expr)
> The following form
> #,(include "foo.scm")
>
> appears to have the same semantics as
> (include "foo.scm")
> in Gambit.
In Gambit, the form (include "foo.scm") operates at macro-expansion
time, after *all* the source code in the file has been read by the
reader. Your implementation, i.e. #,(include "foo.scm"), is not
completely equivalent because it is done at read-time (for example if
"foo.scm" contains #,(define-reader-ctor 'bar ...) then in your
implementation it is valid to have a #,(bar ...) after the #,(include
"foo.scm") in the same file). This is exactly the kind of problem I
was hinting at in my previous message...
Marc