tisp

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

commit 09e53bcc5718f3ff81a428bf841c88ff5b92e5ed
parent dd13b84d825fb06fb2316401378207551266b502
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Mon,  2 Apr 2018 12:53:10 -0700

cxr: Fix confirmation of argument as pair

Also display correct type in error message when it is not a list and add
an error when more than 1 argument is supplied. Fix spelling mistakes as
well

Diffstat:
tisp.c | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tisp.c b/tisp.c @@ -426,10 +426,12 @@ static Val prim_car(Hash env, Val args) { Val v; + if (list_len(args) != 1) + warnf("car: expected 1 argument, received [%d]", list_len(args)); if (!(v = eval_list(env, args))) return NULL; - if (v->t != PAIR) - warnf("car: expected list, recieved type [%d]", car(args)->t); + if (car(v)->t != PAIR) + warnf("car: expected list, received type [%d]", car(v)->t); return car(car(v)); } @@ -437,10 +439,12 @@ static Val prim_cdr(Hash env, Val args) { Val v; + if (list_len(args) != 1) + warnf("cdr: expected 1 argument, received [%d]", list_len(args)); if (!(v = eval_list(env, args))) return NULL; - if (v->t != PAIR) - warnf("cdr: expected list, recieved type [%d]", car(args)->t); + if (car(v)->t != PAIR) + warnf("cdr: expected list, received type [%d]", car(v)->t); return cdr(car(v)); } @@ -449,7 +453,7 @@ prim_cons(Hash env, Val args) { Val v; if (list_len(args) != 2) - warnf("cons: expected 2 arguments, recieved [%d]", list_len(args)); + warnf("cons: expected 2 arguments, received [%d]", list_len(args)); if (!(v = eval_list(env, args))) return NULL; return mk_pair(car(v), car(cdr(v))); @@ -473,7 +477,7 @@ static Val prim_quote(Hash env, Val args) { if (list_len(args) != 1) - warnf("quote: expected 1 argument, recieved [%d]", list_len(args)); + warnf("quote: expected 1 argument, received [%d]", list_len(args)); return car(args); }