tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit 051e2e2f0dc48f6abbd55c69d0db3414948312e5
parent 7f332fcae06fb272248d3c6e156c2a1326c5509d
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Fri,  8 Jan 2021 01:31:55 -0800

Print void so it is self evaluating

Diffstat:
test.c | 39++++++++++++++++++++-------------------
tisp.c | 2+-
2 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/test.c b/test.c @@ -60,12 +60,12 @@ char *tests[][2] = { { "Nil", "Nil" }, { "comments", NULL }, - { "; commment", "#<void>" }, - { "; (+ 1 1)", "#<void>" }, + { "; commment", "(Void)" }, + { "; (+ 1 1)", "(Void)" }, { "(+ 1 ; more comments\n1)", "2" }, { "whitespace", NULL }, - { "\t \n \n\n\t\n \t\n", "#<void>" }, + { "\t \n \n\n\t\n \t\n", "(Void)" }, { "\t \t(+ \t\t5 \n \n5 \n\t)", "10" }, { "quote", NULL }, @@ -102,12 +102,12 @@ char *tests[][2] = { { "(cdr (cdr (cons 1 (cons 2 3))))", "3" }, { "void", NULL }, - { "(Void)", "#<void>" }, + { "(Void)", "(Void)" }, { "do", NULL }, { "(do (+ 1 2) (+ 2 2))", "4" }, { "(do (+ -4 8) (- 1 2) (* 80 0) (+ 39 -3))", "36" }, - { "(do (mod 80 2) (/ 4 2) (Void))", "#<void>" }, + { "(do (mod 80 2) (/ 4 2) (Void))", "(Void)" }, { "eval", NULL }, { "(eval ''hey)", "hey" }, @@ -118,14 +118,14 @@ char *tests[][2] = { { "(do (def bar '(/ 25 5)) (eval bar))", "5" }, { "cond", NULL }, - { "(cond)", "#<void>" }, + { "(cond)", "(Void)" }, { "(cond (True 1))", "1" }, { "(cond ((= 1 1) 1) ((= 1 2) 2) (True 3))", "1" }, { "(cond ((= 1 2) 1) ((= 1 2) 2) (else (+ 1 2)))", "3" }, { "(cond ((= 1 2) 1) ((= 1 1) 2) (else 3))", "2" }, - { "(cond ((= 1 2) 1) ((= 1 3) 2))", "#<void>" }, + { "(cond ((= 1 2) 1) ((= 1 3) 2))", "(Void)" }, { "(cond ((= 1 2) 1) (\"foo\" 2) (else 3))", "2" }, - { "(cond (() (+ 1 2)))", "#<void>" }, + { "(cond (() (+ 1 2)))", "(Void)" }, { "get", NULL }, { "(get \"hello\" 'len)", "5" }, @@ -182,24 +182,24 @@ char *tests[][2] = { { "(= @it (lambda (x) x))", "Nil" }, { "def", NULL }, - { "(def foo 4)", "#<void>" }, + { "(def foo 4)", "(Void)" }, { "foo", "4" }, - { "(def bar foo)", "#<void>" }, + { "(def bar foo)", "(Void)" }, { "bar", "4" }, { "(set! foo 5)", "5" }, { "foo", "5" }, { "(set! foo (+ foo bar))", "9" }, { "foo", "9" }, - { "(def add +)", "#<void>" }, + { "(def add +)", "(Void)" }, { "(add foo bar)", "13" }, - { "(def (one x) (add x 1))", "#<void>" }, + { "(def (one x) (add x 1))", "(Void)" }, { "(one foo)", "10" }, { "(def (more x)" " (def term 3)" - " (+ x term))", "#<void>" }, + " (+ x term))", "(Void)" }, { "(more 8)", "11" }, { "(def (add2 x)" - " (+ x 1) (+ x 2))", "#<void>" }, + " (+ x 1) (+ x 2))", "(Void)" }, { "(add2 2)", "4" }, { "(set! add2 2)", "2" }, { "add2", "2" }, @@ -225,17 +225,18 @@ char *tests[][2] = { { "(if (integer? 3) True ())", "True" }, { "(if (ratio? car) (cons 1 2) (car '(1 2)))", "1" }, { "(when True 'foo)", "foo" }, - { "(when () 'b ar)", "#<void>" }, + { "(when () 'b ar)", "(Void)" }, { "(when (= 1 1) 4)", "4" }, - { "(unless True 'foo)", "#<void>" }, + { "(unless True 'foo)", "(Void)" }, { "(unless () 'bar)", "bar" }, - { "(unless 3 4)", "#<void>" }, + { "(unless 3 4)", "(Void)" }, { "(unless (< 5 4) 7)", "7" }, { "(switch 5 (3 'yes) (5 'no))", "no" }, { "(switch (+ 1 2) ((mod 8 5) 'yes) (err 'no))", "yes" }, - { "(switch 2 (3 'yes) (5 'no))", "#<void>" }, + { "(switch 2 (3 'yes) (5 'no))", "(Void)" }, { "(switch \"foo\" (e \"bar\") (\"foo\" 'zar) ('baz 3))", "zar" }, + /* TODO other syms as well */ { "logic", NULL }, { "(not ())", "True" }, { "(not True)", "Nil" }, @@ -380,7 +381,7 @@ char *tests[][2] = { { "(swap (list 1/2 1/4 1/9 1/16))", "(1/4 1/2 1/9 1/16)" }, { "stack!", NULL }, - { "(def s '(1 2 3 4 5))", "#<void>" }, + { "(def s '(1 2 3 4 5))", "(Void)" }, { "(peek s)", "1" }, { "(pop! s)", "1" }, { "s", "(2 3 4 5)" }, diff --git a/tisp.c b/tisp.c @@ -737,7 +737,7 @@ tisp_print(FILE *f, Val v) { switch (v->t) { case TSP_NONE: - fputs("#<void>", f); + fputs("(Void)", f); break; case TSP_NIL: fputs("Nil", f);