2022-07-16 16:14:19 +00:00
|
|
|
#+TITLE: Where next for guile-prescheme?
|
|
|
|
|
|
|
|
* 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:
|
|
|
|
|
|
|
|
#+BEGIN_SRC scheme
|
|
|
|
(use-modules (system base language))
|
|
|
|
(set-module-name! (default-environment 'prescheme) '(prescheme-user))
|
|
|
|
,module prescheme-user
|
|
|
|
,language prescheme
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
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 translate s48 macros to syntax-case
|
|
|
|
|
|
|
|
Scheme 48 uses "explicit renaming" macros, these should be ported to
|
|
|
|
syntax-case.
|
|
|
|
|
|
|
|
#+BEGIN_SRC scheme
|
|
|
|
;; scheme48-1.9.2/scheme/alt/define-macro-define-syntax.scm
|
|
|
|
(define-macro (define-syntax macro-name transformer . stuff)
|
|
|
|
`(define-macro (,macro-name . args)
|
|
|
|
(,transformer (cons ',macro-name args)
|
|
|
|
(lambda (x) x)
|
|
|
|
eq?)))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** TODO prescheme/s48-defenum.scm
|
|
|
|
- define-enumeration
|
|
|
|
** TODO prescheme/ps-defenum.scm
|
|
|
|
- define-external-enumeration
|
2022-07-18 01:22:49 +00:00
|
|
|
** DONE prescheme/prescheme.scm
|
2022-07-16 16:14:19 +00:00
|
|
|
- goto
|
|
|
|
- external
|
|
|
|
|
2022-07-18 01:23:47 +00:00
|
|
|
* 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...
|
|
|
|
|
2022-07-16 16:14:19 +00:00
|
|
|
* 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:
|
|
|
|
|
|
|
|
#+BEGIN_SRC scheme
|
|
|
|
;; 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)))
|
|
|
|
#+END_SRC
|
|
|
|
|
2022-07-18 01:23:47 +00:00
|
|
|
A bunch of tests are included in scheme48-1.9.2/ps-compiler/prescheme/test.
|
|
|
|
Nice!
|
|
|
|
|
2022-07-16 16:14:19 +00:00
|
|
|
* TODO write more TODOs
|