"Pure" r7rs compiler and interpreter.
"Pure" = only (scheme base) by default, no scheme, (chicken base), or (chicken syntax)
The core of r7rs-tools. Uses a hack around ##sys#current-environment and ##sys#macro-environment to set the environment to only include procedures and syntax from (scheme base). You can manually reset the environment to (scheme base) by using (import r7rs-env).
The following is the full implementation of this module:
(module r7rs-env () (import (scheme base) (scheme eval) (srfi 1)) (define env (environment '(only chicken.base exit))) (##sys#current-environment (##sys#slot env 2)) (##sys#macro-environment (filter-map (lambda (e) (and (list? e) e)) (##sys#slot env 2))))
The r7csc program is equivalent to the following invocation of csc:
csc -x -X r7rs -R r7rs -uses library -X r7rs-env -R r7rs-env [args ...]
This makes csc compile with an initial environment containing only exports of (scheme base).
The r7csi program is equivalent to the following invocation of csi:
csi -R r7rs-env [args ...]
This starts csi with an initial environment containing only exports of (scheme base)
The implementation currently uses CHICKEN internals because I couldn't really find a satisfactory way to achieve it otherwise, which means it may be subject to more instability with new updates to the core system.
I'm not an expert on the internals, so at the end of the day this is simply a best effort through kludges and trial and error that seems to work. More testing may still be required. Suggestions and improvements welcome!
- Initial release