2.9 KiB
Where next for guile-prescheme?
- guile repl integration
- script to build each module
- fix missing symbols in prescheme
- start porting ps-compiler
- prepare some compatibility tests
- write more TODOs
TODO guile repl integration
Currently the "prescheme" language definition is just scheme with a different default environment (aka. the "prelude", the stuff that's imported by default).
In the Guile REPL you can ,L prescheme
to switch language, but it's not very
useful because you stay in the guile-user module, which is Guile's default
environment, not Pre-Scheme's!
You can create a Pre-Scheme module and switch into it with some effort:
(use-modules (system base language))
(set-module-name! (default-environment 'prescheme) '(prescheme-user))
,module prescheme-user
,language prescheme
We need to make the process of "give me a Pre-Scheme REPL" easier. Maybe just ship a REPL launcher script which starts up in Pre-Scheme instead of Guile?
TODO script to build each module
We can use guile compile
to get useful warnings:
find -name '*.scm' | xargs -n1 guild compile -W3 -O0 | grep -v '^wrote'
TODO fix missing symbols in prescheme
warning: possibly unbound variable `make-code-vector' warning: possibly unbound variable `assertion-violation' warning: possibly unbound variable `code-vector-ref' warning: possibly unbound variable `code-vector-set!' warning: possibly unbound variable `write-byte' warning: possibly unbound variable `byte-ready?' warning: possibly unbound variable `peek-byte' warning: possibly unbound variable `read-byte' warning: possibly unbound variable `code-vector-length'
TODO start porting ps-compiler
Above is just the emulation layer. The real work is the ps-compiler itself, which is written in Scheme 48 (and also Common Lisp apparently). This will involve:
- rewrite s48 interfaces as guile modules
- rewrite code using records to use Guile's (or emulate s48?)
- rewrite macros from explicit renaming to syntax-case
- … and many more unforeseen challenges…
TODO prepare some compatibility tests
We need to find collect all the "real-world" Pre-Scheme we can get our hands on, and test that our Guile Pre-Scheme produces identical output to Scheme 48 Pre-Scheme.
Exhibit A is the "hello world" from the manual:
;; https://thintz.com/resources/prescheme-documentation#Example-Pre_002dScheme-compiler-usage
(define (main argc argv)
(if (= argc 2)
(let ((out (current-output-port)))
(write-string "Hello, world, " out)
(write-string (vector-ref argv 1) out)
(write-char #\! out)
(newline out)
0)
(let ((out (current-error-port)))
(write-string "Usage: " out)
(write-string (vector-ref argv 0) out)
(write-string " <user>" out)
(newline out)
(write-string " Greets the world & <user>." out)
(newline out)
-1)))
A bunch of tests are included in scheme48-1.9.2/ps-compiler/prescheme/test. Nice!