diff --git a/HACKING b/HACKING new file mode 100644 index 00000000..20ae95a3 --- /dev/null +++ b/HACKING @@ -0,0 +1,37 @@ +-*-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 diff --git a/TODO b/TODO index 19bdfd9e..e37e1be8 100644 --- a/TODO +++ b/TODO @@ -5,17 +5,7 @@ Using define-macro-based version. ** 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/ diff --git a/c2.mes b/bugs/c2.mes similarity index 100% rename from c2.mes rename to bugs/c2.mes diff --git a/c4.mes b/bugs/c4.mes similarity index 100% rename from c4.mes rename to bugs/c4.mes diff --git a/bugs/compare.scm b/bugs/compare.scm new file mode 100644 index 00000000..2ffab3eb --- /dev/null +++ b/bugs/compare.scm @@ -0,0 +1,10 @@ +(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) diff --git a/c0.mes b/c0.mes deleted file mode 100644 index 437bf7ca..00000000 --- a/c0.mes +++ /dev/null @@ -1,21 +0,0 @@ - -;; 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) -"" diff --git a/c1.mes b/c1.mes deleted file mode 100644 index e5cf0123..00000000 --- a/c1.mes +++ /dev/null @@ -1,44 +0,0 @@ - -;; 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) -"" diff --git a/c3.mes b/c3.mes deleted file mode 100644 index 0c1d8afb..00000000 --- a/c3.mes +++ /dev/null @@ -1,13 +0,0 @@ -;; guile: 01 -;; mes: 00 -(define free 0) - -(define bla #f) -(let () - (set! bla (lambda () free)) - #t) - -(display (bla)) -(set! free 1) -(display (bla)) -(newline) diff --git a/c5.mes b/c5.mes deleted file mode 100644 index e392d225..00000000 --- a/c5.mes +++ /dev/null @@ -1,16 +0,0 @@ -;; guile: 00 -;; mes: segfault -;; (display -;; (let ((count (let ((counter 0)) -;; (lambda () -;; counter)))) -;; (count))) - -(display - ((lambda (count) - (count)) - ((lambda (counter) - (lambda () - counter)) - 0))) -(newline) diff --git a/closure.mes b/closure.mes deleted file mode 100644 index 100e6b07..00000000 --- a/closure.mes +++ /dev/null @@ -1,28 +0,0 @@ - -;; 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))) diff --git a/let.mes b/let.mes deleted file mode 100644 index 57ed2104..00000000 --- a/let.mes +++ /dev/null @@ -1,40 +0,0 @@ -(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) diff --git a/x2.mes b/x2.mes deleted file mode 100644 index 4cd3d0aa..00000000 --- a/x2.mes +++ /dev/null @@ -1,13 +0,0 @@ - -(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)) diff --git a/x3.mes b/x3.mes deleted file mode 100644 index ed0765d5..00000000 --- a/x3.mes +++ /dev/null @@ -1,12 +0,0 @@ -(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)) -