tisp

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

commit ad9fddcee09a0b17330ae632f7e77978ba14fbcb
parent 71245640e69ee80bba56fe634b3ab1ed0880a135
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Tue, 15 Oct 2019 17:36:47 -0700

cond return void not nil if no conditions are met

Diffstat:
test.c | 6+++---
tibs/lib.tsp | 4++--
tisp.c | 2+-
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/test.c b/test.c @@ -118,14 +118,14 @@ char *tests[][2] = { { "(do (define bar '(/ 25 5)) (eval bar))", "5" }, { "cond", NULL }, - { "(cond)", "()" }, + { "(cond)", "" }, { "(cond (t 1))", "1" }, { "(cond ((= 1 1) 1) ((= 1 2) 2) (t 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))", "()" }, + { "(cond ((= 1 2) 1) ((= 1 3) 2))", "" }, { "(cond ((= 1 2) 1) (\"foo\" 2) (else 3))", "2" }, - { "(cond (() (+ 1 2)))", "()" }, + { "(cond (() (+ 1 2)))", "" }, { "eq", NULL }, { "(=)", "t" }, diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -58,10 +58,10 @@ (define else t) (define when (macro (con . body) - (list 'cond (list con (cons 'do body)) (list t (void))))) + (list 'cond (list con (cons 'do body))))) (define unless (macro (con . body) - (list 'cond (list con (void)) (list t (cons 'do body))))) + (list 'cond (list (list not con) (cons 'do body))))) (define let (macro (vars . body) (cons (list* 'lambda (map car vars) body) (map cadr vars)))) diff --git a/tisp.c b/tisp.c @@ -890,7 +890,7 @@ prim_cond(Env env, Val args) return NULL; else if (!nilp(cond)) return tisp_eval(env, car(cdar(v))); - return env->nil; + return env->none; } /* return type of tisp value */