--> ap/xxxxx

* __

SICP code from Chapter 4: Metalinguistic Abstraction (2007.01.05:4 lisp#5 research#128 scheme#2)

Running the meta-circular evaluator on MzScheme requires a few changes to the code:

to figure out:

(define (eval exp env)
  (cond ((self-evaluating? exp) exp)
        ((variable? exp) (lookup-variable-value exp env))
        ((quoted? exp) (text-of-quotation exp))
        ((assignment? exp) (eval-assignment exp env))
        ((definition? exp) (eval-definition exp env))
        ((if? exp) (eval-if exp env))
        ((lambda? exp)
         (make-procedure (lambda-parameters exp)
                         (lambda-body exp)
        ((begin? exp) 
         (eval-sequence (begin-actions exp) env))
        ((cond? exp) (eval (cond->if exp) env))
        ((application? exp)
         (apply (eval (operator exp) env)
                (list-of-values (operands exp) env)))
         (error "Unknown expression type -- EVAL" exp))))


(define (make-procedure parameters body env)
  (list 'procedure parameters body env))

list expression arrives by default at apply which separates into operator and operands by way of car and cdr - this is sent again to eval with the environment - primitive is looked up as variable and we have as procedure:

(primitive #)

which tests correctly by way of tagged-list? as a primitive:

<(define (tagged-list? exp tag)
  (if (pair? exp)
      (eq? (car exp) tag)

which is then applied using underlying Scheme apply

Chaitin's Lisp interpreter: (2007.01.02:4 atmegascheme#4 lisp#4)


The Art of the Interpreter of, the Modularity Complex (Parts Zero, One, and Two) (2007.01.02:3 atmegascheme#3 tech_notes#333 cpu#8 lisp#3 scheme#1)


further Scheme research:

icbins: from http://www.accesscom.com/~darius/

with further interesting code there...

from the README from icbins:

Here we have an exercise in stripping a Lisp to barest essentials, dropping the host tether early, and repeatedly changing and rebuilding, to practice evolving a self-hosted system. Only the garbage collector and the lowest-level Lisp primitives are in C. The source is an order of magnitude smaller than the already-lightweight UTS's. You might find this of interest if you want to do similar exercises or if you'd just like to read a tiny Lisp system with no magic (small self-hosting Lisps typically rely on powerful primitives like READ, PRINT, and GC). This could be cut down further; hopefully I'll come back to it someday.

Dream Scheme interpreter: (2006.12.31:1 tech_notes#330 research#124 lisp#2)

in x86 assembly



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


SIOD porting

Explicit-Control Evaluator (2006.12.30:3 tech_notes#329 research#123 lispcpu#5 lisp#1)

again, chapter five of SICP:

from: http://www.ida.liu.se/~tobnu/scheme2llvm/

This is a small (about 1K lines) self applicable scheme toy compiler which compiles to C-code, and a version that compiles to LLVM with the types fixnum, symbols, strings, functions and vectors (cons cells are seen as vectors of size 2).


The code is quite similar to the code in SICP (Structure and Interpretation of Computer Programs), chapter five, with the difference that it implements the extra functionality that SICP assumes that the explicit control evaluator (virtual machine) already have. Much functionality of the compiler is implemented in a subset of scheme, c-defines (llvm-defines), which are compiled to C-functions (llvm functions).

code for SICP at: