[plt-scheme] Injecting syntax into load

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Thu Dec 7 05:49:10 EST 2006


Can anyone tell me how I would inject new syntax into the syntax  
transformer used by LOAD, in such a way that REQUIRE in the loaded  
file works?

I can see how to do something similar to this in the R5RS case with  
eval, quasiquote and let-syntax:

(define prog '((foo 99) (display "hello"))) ; read from file
(define (run-it p)
   (eval `(let-syntax ((foo (syntax-rules ()
                              ((_ x) (display (format "--~a--~%" x))))))
            , at p)))
(run-it prog)

but that doesn't work if the loaded file has module requirements (or  
even if it has definitions following expressions), since these can  
only appear at the top level.

So a variant of that question would be: is there any way to modify  
run-it above, so that the argument is effectively at the top-level?   
Or more fundamentally: how is load implemented in terms of eval?

I think the remark in section 14.1 that ``(load file-path) evaluates  
each expression in the specified file using eval.'' may not be the  
complete story (!), and its footnote leads to a maze of twisty  
passages, all different.  So a pointer into the docs, or other  
appropriate reading, would be most welcome.

[I asked a similar question here a couple of days ago, but I suspect  
it rambled somewhat]

All the best,


Norman Gray  /  http://nxg.me.uk
eurovotech.org  /  University of Leicester, UK

Posted on the users mailing list.