A port of Pre-Scheme from Scheme 48 to Guile

Andrew Whatson 382789414d Update homepage to notabug.org 1 年間 前
doc 97b7bba23a Rest of files we want to customize generated by Hall, gitignore the rest 2 年 前
language 92c5c34884 Add define-record-type emulation 2 年 前
prescheme d793730895 Port prescheme filename and stub prescheme env 2 年 前
ps-compiler d793730895 Port prescheme filename and stub prescheme env 2 年 前
.dir-locals.el 5dfab7f282 Initial work on guile-prescheme port 2 年 前
.envrc a661cb60a9 Updates to hall configuration 2 年 前
.gitignore 97b7bba23a Rest of files we want to customize generated by Hall, gitignore the rest 2 年 前
AUTHORS 97b7bba23a Rest of files we want to customize generated by Hall, gitignore the rest 2 年 前
COPYING 74363d764f Stub README and COPYING 2 年 前
HACKING a4e529db26 Initial version of hall.scm and the things it pulls in 2 年 前
NEWS e0df0bde50 Inserted email there 2 年 前
README.org f3f403c6fb Update homepage to notabug.org 1 年間 前
TODO.org dea69cf049 Port scheme bcomp syntax package 2 年 前
guix.scm 382789414d Update homepage to notabug.org 1 年間 前
hall.scm 382789414d Update homepage to notabug.org 1 年間 前

README.org

This project is a work-in-progress port of the Pre-Scheme compiler from Scheme 48 to Guile. Pre-Scheme is a statically typed dialect of Scheme which offers the efficiency and low-level machine access of C while retaining many of the desirable features of Scheme.

Read the Pre-Scheme manual here.

Read the Pre-Scheme paper here.

Where is it up to?

An initial Pre-Scheme "emulation layer" has been implemented, which supports running Pre-Scheme code in a Guile Scheme interpreter. This includes features like the define-enumeration and define-external-enumeration macros and a fake memory driver which supports allocate-memory, deallocate-memory.

This is a very fresh port which still requires a good deal of testing and probably a few rounds of fixes before being considered "complete".

Work continues on porting the Pre-Scheme to C compiler.

How can I play with it?

Running the Pre-Scheme emulator

To play with the Pre-Scheme interpreter, you will need git and guile. Clone the repo and start a Guile REPL with guile-prescheme added to your load-path:


guix shell git guile
git clone https://notabug.org/flatwhatson/guile-prescheme.git
cd guile-prescheme
guile -L .

In the Guile REPL, load the Pre-Scheme environment and switch to the Pre-Scheme language:


(use-modules (system base language))
(set-current-module (default-environment 'prescheme))
,language prescheme

Your REPL is now emulating Pre-Scheme!

Hello, world, Pre-Scheme!

Load up a Pre-Scheme REPL as above, then paste in the following program:


(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 Pre-Scheme main takes ARGC as an int and ARGV as a vector of strings. As with a C program, the first argument is the name of the program which was run.

To get the help output:


> (main 1 #("./hello"))
Usage: ./hello <user>
  Greets the world & <user>.
-1

To get the greeting:


> (main 2 #("./hello" "Pre-Scheme"))
Hello, world, Pre-Scheme!
0

How can I contribute?

If you would like to learn more, co-ordinate with the developers, or simply hang out with like-minded Scheme folks, come and join the party in the #guile-steel channel on the LiberaChat IRC network.