From bc874e8ecc8b0f39b08dc911670c00e0b848753e Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Wed, 22 Feb 2023 15:58:56 +0200 Subject: [PATCH] Wayback 20060529104413 www.stripedgazelle.org/joey/dream.html --- www/index.html | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/www/index.html b/www/index.html index f33411a..86ad727 100644 --- a/www/index.html +++ b/www/index.html @@ -1,19 +1,23 @@ +The 'dream' Scheme Interpreter

The 'dream' Scheme Interpreter

-
Download source (gcc on PowerPC): dream_ppc.tar.gz
-
Download source (gcc on x86): dream_x86.tar.gz
+by David Joseph Stith

I am proud to announce the premier production version of my Scheme interpreter, 'dream', written entirely in assembly language (GAS syntax.) :-) -All essential syntax and procedures from the R4RS standard are implemented. -The interpreter passes all applicable tests from the 'r4rstest.scm' test suite. +All essential syntax and procedures from the R4RS standard are implemented. +The interpreter is properly tail recursive and passes all applicable tests from the 'r4rstest.scm' test suite. +Rational arithmetic with 32 bit numerator and denominator is supported, but no Real or Complex numbers. My overarching goal has been SIMPLICITY. I have chosen a design and implementation that is as straightforward and direct as I could imagine. The result is an executable that is quite small and, for an interpreter, quite fast as well. :-)

+
Download source (gcc on PowerPC): dream_ppc.tar.gz
+
Download source (gcc on x86): dream_x86.tar.gz
+
Download source (gcc-mingw on x86): dream_x86_mingw.zip

Notes on the Design of the 'dream' Scheme Interpreter

-The design for the 'dream' Scheme interpreter began with the design given in Abelson and Sussman's Structure and Interpretation of Computer Programs. +The design for the 'dream' Scheme interpreter began with the design given in Abelson and Sussman's Structure and Interpretation of Computer Programs.

Garbage Collection

@@ -58,8 +62,8 @@ When combinations are evaluated, if the 'car' of the combination is a symbol of This way, each time this combination is evaluated afterwards, the symbol lookup in the top-level environment will no longer be necessary, and the efficiency of the interpreter is greatly enhanced. However, the R4RS standard for scheme requires that these symbols, bound to built-in procedures, may be redefined, and we may presume that any redefinition should then be effective retroactively for all occurences of the symbol within the same environment. The memoizing technique described above is inconsistent with this requirement. -Therefore, symbols of the type MEMOIZABLE_SYMBOL are allowed by R4RS to be bound only to special forms. -Consequently, we provide this standards compliant behavior as a conditional compilation option, but for efficiency's sake we retain memoization of built-in procedures as the default. +Therefore, symbols of the type MEMOIZABLE_SYMBOL are allowed by R4RS to be bound only to special forms. +Consequently, we make this standards compliant behavior the default, but for efficiency's sake we provide memoization of built-in procedures as a conditional compilation option.

Number types are distinguished by the high byte of the low word, which increases as the complexity of the type of number ascends the numeric tower. Integers simply store their 32 bit signed value in the second half of the quad-word. Rationals are stored as a pair of integers, thus the low bit in the high byte of the low word of their type is set so that the garbage collector will see the pair. Inexactness of a number is indicated by setting the lowest bit of the high word of the number's type. Note, however, that all internal representations of numbers are exact (no floating point numbers are used), and so inexactness is given only as an auxiliary property of the number. @@ -68,7 +72,7 @@ Number types are distinguished by the high byte of the low word, which increases

Input ports use the low byte of the high word of the type field to store the last character read by the (peek) procedure. The second half of the quad-word for both input and output ports holds the FILE* pointer associated with the port. The ports returned by (current-input-port) and (current-output-port) are stored internally for efficiency's sake. -They therefore must be treated by the garbage collector as if they were registers (which indeed they would be if only we had more registers to work with). +They therefore must be treated by the garbage collector as if they were registers (which indeed they are in the register-rich PowerPC version).

The Stack

The scheme object stack is maintained as a scheme list (dynamically allocated as pairs). @@ -79,7 +83,7 @@ Consequently when call-with-current-continuation is invoked, this native stack i

Scheme Registers

-The registers denoted by EXP, ENV, UNEV, ARGL, VAL, FREE, OLD, NEW, and SCAN in Structure and Interpretation of Computer Programs are defined via preprocessor macros to the machine registers that implement them. +The registers denoted by EXP, ENV, UNEV, ARGL, VAL, FREE, OLD, NEW, and SCAN in Structure and Interpretation of Computer Programs are defined via preprocessor macros to the machine registers that implement them. EXP, ENV, UNEV, ARGL, and VAL must point to a valid scheme object (or null) when the garbage collector is invoked.

Input/Output