[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What #,(foo) does tell... include vs. load

This page is part of the web mail archives of SRFI 10 from before July 7th, 2015. The new archives for SRFI 10 contain all messages, not just those from before July 7th, 2015.



> 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