--> ap/xxxxx

* __

quotation: (2007.07.16:1)

Allowing quotation in a language wreaks havoc with the ability to reason about the language in simple terms, because it destroys the notion that equals can be substituted for equals. For example, three is one plus two, but the word “three” is not the phrase “one plus two.” Quotation is powerful because it gives us a way to build expressions that manipulate other expressions (as we will see when we write an interpreter in chapter 4). But allowing statements in a language that talk about other statements in that language makes it very difficult to maintain any coherent principle of what “equals can be substituted for equals” should mean. For example, if we know that the evening star is the morning star, then from the statement “the evening star is Venus” we can deduce “the morning star is Venus.” However, given that “John knows that the evening star is Venus” we cannot infer that “John knows that the morning star is Venus.”

[SICP. p142]

Quack: enhances Emacs support for Scheme programming. (2007.01.10:1 research#131 scheme#3 emacs#13 tech_notes#4)


1] download and (require 'quack) in .emacs


2] default fontlock for ;;; comments (three semicolons) is blue text-invisible bars. change this with:

(setq quack-fontify-threesemi-p nil)

3] Key bindings:

;;     The key bindings that Quack adds to `scheme-mode' include:
;;         C-c C-q m   View a manual in your Web browser.
;;         C-c C-q k   View the manual documentation for a keyword
;;                     (currently only works for PLT manuals).
;;         C-c C-q s   View an SRFI. (Scheme Requests for Implementation)
;;         C-c C-q r   Run an inferior Scheme process.
;;         C-c C-q f   Find a file using context of point for default.
;;         C-c C-q l   Toggle `lambda' syntax of `define'-like form.
;;         C-c C-q t   Tidy the formatting of the buffer.

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

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.