--- /dev/null
+-*-mode:org-*-
+* Booting from LISP-1.5 into Mes
+
+Mes started out experimenting with booting from a hex-coded minimal
+LISP-1.5 (prototype in mes.c), into an intepreted full-flegded Scheme.
+
+When EOF is read, the LISP-1.5 machine calls loop2 from loop2.mes,
+which reads the rest of stdin and takes over control. The functions
+readenv, eval and apply-env in mes.mes introduced define, define-macro
+quasiquote and macro expansion.
+
+While this works, it's amazingly slow. We implemented a full reader
+in mes.c, which makes running mes:apply-env mes:eval somewhat
+bearable, still over 1000x slower than running mes.c.
+
+Bootstrapping has been removed and mes.c implements enough of R3RS to
+run a macro-based define-syntax and syntax-rules.
+
+loop.mes and mes.mes are unused and lagging behind. Probably it's not
+worth considering this route without a VM. GNU Epsilon is taking the
+more usual VM-route to provide multiple personas. While that sounds
+very cool, Lisp/Scheme, bootstrapping and trusted binaries are
+probably not in scope as there is no mention of such things; only ML
+is mentioned while Guile is used for bootstrapping.
+
+mes.c is ~1200 lines which seems much too big to start translating it
+to assembly/hex.
+
+* Garbage collection
+Mes is using malloc without freeing anything, memory is patient these
+days :-)
+
+* The [GuixSD] boostrap binaries
+** Run a C parser on Mes
+*** Find/port a PEG C and parse minimal C program
+*** Generate an executable from this C-AST
+*** Find a tiny C compiler that can compile gcc
** psyntax.pp
Find out how to hook-up sc-expand in eval/apply.
** bugs
-*** c2.mes
-*** c4.mes
-*** v c5.mes
-*** v c0.mes
-*** v closure.mes
-*** v c1.mes
-*** v c3.mes
-*** v using (let () ...) in macro.mes/syntax.mes
-*** v syntax.mes: closuring name? etc in syntax.mes
-*** v syntax.mes: closuring: indicators: eval: no such symbol: ---
-*** <=, => take only 2 arguments
+See bugs/
** run PEG
** parse C using PEG
http://piumarta.com/software/peg/
--- /dev/null
+;; guile
+#!
+;;; compiling /home/janneke/src/mes/c2.mes
+joepie-complie
+;;; compiled /home/janneke/.cache/guile/ccache/2.2-LE-8-3.7/home/janneke/src/mes/c2.mes.go
+joepie
+jippie
+!#
+
+;;mes
+
+
+(define-macro (bla naam de-lambda)
+ `(define-macro (,naam . rest)
+ (,de-lambda)))
+
+(bla joepie
+ (let ()
+ (lambda ()
+ (list 'begin
+ (list 'display "joepie")
+ (list 'newline)
+ (and
+ (display "joepie-complie")
+ (newline)
+ "jippie")))))
+
+(display "compiled")
+(newline)
+(display (joepie 'x))
+(newline)
+
--- /dev/null
+;; guile: g0
+;; mes: crash
+(define gensym
+ (let ((counter 0))
+ (lambda (. rest)
+ (let ((value (number->string counter)))
+ (set! counter (+ counter 1))
+ (string->symbol (string-append "g" value))))))
+
+(display (gensym))
+(newline)
--- /dev/null
+(display (< 1 2 3))
+(newline)
+(display (<= 1 2 2))
+(newline)
+(display (= 1 1 1))
+(newline)
+(display (>= 3 2 1))
+(newline)
+(display (>= 2 2 1))
+(newline)
+++ /dev/null
-
-;; guile:
-;; 0
-;; 0
-
-;; mes:
-;; 0
-;; 1
-
-(define b 0)
-(define x (lambda () b))
-(define (x) b)
-
-(display (x))
-(newline)
-(define (c b)
- (display (x))
- (newline)
- (x))
-(c 1)
-""
+++ /dev/null
-
-;; guile: 10
-;; (0 0)
-;; mes: 10
-;; (0 2)
-
-(define (x)
- (define b 1)
- (define (y) b)
-
- (display b)
- (set! b 0)
- (display b)
- (newline)
-
- (list b
- (let ((b 2)) ;; b shadows previous b in mes
- (y)))) ;; guile: y captures shadowed b, mes: y runs in context new b
-
-(display (x))
-(newline)
-""
-
-;; guile: 10
-;; (0 3)
-;; mes: 10
-;; (0 3)
-(define (x)
- (define b 1)
- (define (y) b) ;; var b is captured
-
- (display b)
- (set! b 0)
- (display b)
- (newline)
-
- (list b
- (let ((d 4))
- (set! b 3) ;; value b is changed
- (y))))
-
-(display (x))
-(newline)
-""
+++ /dev/null
-;; guile
-#!
-;;; compiling /home/janneke/src/mes/c2.mes
-joepie-complie
-;;; compiled /home/janneke/.cache/guile/ccache/2.2-LE-8-3.7/home/janneke/src/mes/c2.mes.go
-joepie
-jippie
-!#
-
-;;mes
-
-
-(define-macro (bla naam de-lambda)
- `(define-macro (,naam . rest)
- (,de-lambda)))
-
-(bla joepie
- (let ()
- (lambda ()
- (list 'begin
- (list 'display "joepie")
- (list 'newline)
- (and
- (display "joepie-complie")
- (newline)
- "jippie")))))
-
-(display "compiled")
-(newline)
-(display (joepie 'x))
-(newline)
-
+++ /dev/null
-;; guile: 01
-;; mes: 00
-(define free 0)
-
-(define bla #f)
-(let ()
- (set! bla (lambda () free))
- #t)
-
-(display (bla))
-(set! free 1)
-(display (bla))
-(newline)
+++ /dev/null
-;; guile: g0
-;; mes: crash
-(define gensym
- (let ((counter 0))
- (lambda (. rest)
- (let ((value (number->string counter)))
- (set! counter (+ counter 1))
- (string->symbol (string-append "g" value))))))
-
-(display (gensym))
-(newline)
+++ /dev/null
-;; guile: 00
-;; mes: segfault
-;; (display
-;; (let ((count (let ((counter 0))
-;; (lambda ()
-;; counter))))
-;; (count)))
-
-(display
- ((lambda (count)
- (count))
- ((lambda (counter)
- (lambda ()
- counter))
- 0)))
-(newline)
+++ /dev/null
-
-;; guile:
-;; closure path=(3 2 1)
-;; closure path=()
-;; mapit path=(3 2 1)
-;; closure path=(2 1)
-
-;; mes:
-;; closure path=(3 2 1)
-;; closure path=()
-;; mapit path=()
-;; ()
-
-
-(define (closure start? path mapit)
- (display "closure path=") (display path) (newline)
- (cond (start?
- (closure #f '() ;;path
- (lambda (x)
- (display "mapit path=") (display path) (newline)
- (cond ((null? path) path)
- (#t
-
- (closure #f (cdr path) mapit)
- )))))
- (#t (mapit path))))
-
-(closure #t '(3 2 1) (lambda (x) (display "dun") (newline)))
+++ /dev/null
-(define (split-params bindings params)
- (cond ((null? bindings) params)
- (#t (split-params (cdr bindings)
- (append params (cons (caar bindings) '()))))))
-
-(define (split-values bindings values)
- (cond ((null? bindings) values)
- (#t (split-values (cdr bindings)
- (append values (cdar bindings) '())))))
-
-(define-macro (simple-let bindings rest)
- `((lambda ,(split-params bindings '()) ,@rest)
- ,@(split-values bindings '())))
-
-(define-macro (let-loop label bindings . rest)
- `(let ((,label *unspecified*))
- (let ((,label (lambda ,(split-params bindings '()) ,@rest)))
- (,label ,@(split-values bindings '())))))
-
-(define-macro (let-loop label bindings rest)
- `((lambda (,label)
- (display "loop") (newline)
- (set! ,label (lambda ,(split-params bindings '()) ,@rest))
- (,label ,@(split-values bindings '())))
- *unspecified*))
-
-(define-macro (let bindings-or-label . rest)
- `(cond (,(symbol? bindings-or-label)
- (let-loop ,bindings-or-label ,(car rest) ,(cdr rest)))
- (#t (simple-let ,bindings-or-label ,rest))))
-
-(display (let ((a "b"))
- (display "A: ") (display a) (newline) a))
-
-(display (let loop ((lst '(1 2 3)))
- (display "LOOP")
- (newline)
- (cond ((null? lst) '(dun))
- (#t (cons (car lst) (loop (cdr lst)))))))
-(newline)
+++ /dev/null
-
-(define foo
- (lambda ()
- (define name? symbol?)
- (lambda ()
- (display "boo: ")
- (display (name? 'boo))
- (newline))))
-
-;;; ((foo)) ==>
-;;; (lambda () (display boo: ) (display (name? (quote boo))) (newline))
-;;; apply_env fn=(*lambda* 97 () (display boo: ) (display (name? (quote boo))) (newline)) x=()
-((foo))
+++ /dev/null
-(define name? 2)
-(define (foo)
- (define name? 0)
- (lambda ()
- name?))
-
-;;; ((foo)) ==>
-;;; (lambda () (display boo: ) (display (name? (quote boo))) (newline))
-;;; apply_env fn=(*lambda* 97 () (display boo: ) (display (name? (quote boo))) (newline)) x=()
-(display ((foo)))
-;;(display (foo))
-