Update documentation, remove old bug files, move bugs into bugs/.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-22 22:12:05 +02:00
parent efdd84b4c4
commit e63f3b2ee4
13 changed files with 48 additions and 198 deletions

37
HACKING Normal file
View file

@ -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

12
TODO
View file

@ -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/

View file

View file

10
bugs/compare.scm Normal file
View file

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

21
c0.mes
View file

@ -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)
""

44
c1.mes
View file

@ -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)
""

13
c3.mes
View file

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

16
c5.mes
View file

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

View file

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

40
let.mes
View file

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

13
x2.mes
View file

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

12
x3.mes
View file

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