1. r7rs-tools
    1. r7rs-env module
    2. r7csc program
    3. r7csi program
    4. Caveats
    5. Author
    6. Repository
    7. Version history
    8. License

r7rs-tools

"Pure" r7rs compiler and interpreter.

"Pure" = only (scheme base) by default, no scheme, (chicken base), or (chicken syntax)

r7rs-env module

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))))

r7csc program

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).

r7csi program

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)

Caveats

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!

Author

Diego A. Mundo

Repository

https://git.sr.ht/~dieggsy/r7rs-tools/

Version history

0.1.0
Initial release

License

Public Domain