(require 'stdlib) ;; foldoc::bootstrap ;;1. (From "to pull oneself up by one's bootstraps") ;;To load and initialise the operating system on a computer. Normally ;;abbreviated to "boot". ;;See bootstrap loader. ;;2. (From "to pull oneself up by one's bootstraps") to use a ;;compiler to compile itself. ;;The usual process is to write an interpreter for a language, L, in an ;;existing language, M. The compiler is then written in L and the ;;interpreter is used to run it. This produces an executable for ;;compiling programs in L from the source of the compiler in L. ;;This technique is often used to verify the correctness of a ;;compiler. It was first used in the LISP community. ;;See also my favourite toy language. ;; example language L: ;; var a, b, c ;; a = 0 ;; b = 5 ;; c = 42 ;; while a < b ;; print a ;; a = a + 1 ;; end ;; if a == b ;; print c ;; end ;; ---------------------------------------------------------------------- ;; TODO write a simple interpreter for m-expressions, then write a ;; mexp->sexp compiler in mexp, and compile the compiler using the mexp ;; interpreter ;;What is an M-expression (M-expr)? ;;A meta expression. This is the (never completely defined?) external ;;syntax originally intended for LISP. Originally, S-expressions were ;;only intended for the internal representation of symbolic expressions ;;while M-expressions should have been used for writing LISP ;;programs. When the first LISP interpreter became available (at a point ;;where nobody had expected it), people started using S-expressions to ;;program it and finally, the idea of translating (more readable) ;;M-expressions into S-expressions was dropped. However, M-expressions ;;were used in many LISP-related documents. ;;The following list of M-exprs and equivalent S-exprs provides a rough ;;translation scheme. ;;M-expression S-expression ;;x X ;;x.y (X.Y) ;;[x;y;z] (X Y Z) ;;g[x] (G X) ;;car[x] (CAR X) ;;cdr[x] (CDR X) ;;cons[x;y] (CONS X Y) ;;atom[x] (ATOM X) ;;null[x] (NULL X) ;;eq[x;y] (EQ X Y) ;;x \/ y (OR X Y) (*1) ;;x /\ y (AND X Y) (*2) ;;g[x] = eq[x;T] -> nil ; T (DEFUN G (X) (COND ((EQ X T) NIL) (T T))) ;;p -> x ; q -> y ; z (COND (P X) (Q Y) (T Z)) ;;(*1) (DEFUN OR (X Y) (COND ((EQ X T) T) (T Y))) ;;(*2) (DEFUN AND (X Y) (COND ((NULL X) NIL) (T Y)))