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

- 1] Change bare false to #f and true to #t
- 2] Watch for multiple evaluations which screw up apply/underlying Scheme apply distinction

to figure out:

- how a procedure is constructed and evaluated (with lambda)

(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) env)) ((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))) (else (error "Unknown expression type -- EVAL" exp)))) ;;; (define (make-procedure parameters body env) (list 'procedure parameters body env))

- exactly how evaluation of a primitive works:

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) #f))

which is then applied using underlying Scheme apply

http://www.cs.auckland.ac.nz/CDMTCS/chaitin/lisp.c

http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-453.pdf

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.

in x86 assembly

http://www.stripedgazelle.org/joey/dream.html

note:

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

also:

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).

and:

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: