summaryrefslogtreecommitdiff
path: root/lisp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lisp.c')
-rw-r--r--lisp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp.c b/lisp.c
index a559330..4e143f1 100644
--- a/lisp.c
+++ b/lisp.c
@@ -222,7 +222,7 @@ value *eval(env *e, value *v) {
if (!found) {
printf("symbol %s not found\n", v->as.sym);
return cons(make_symbol("quote"),
- cons(v, make_nil()));
+ cons(v, make_nil())); //TODO: return error
}
return found;
}
@@ -318,9 +318,13 @@ value *apply(value *lval, value *args) {
value *result = eval(sub_env, lval->as.lambda.body);
// if arguments left, try applying them to evaluated lambda
- if (arg->type == VT_PAIR) {
+ if (arg->type == VT_PAIR && result->type == VT_LAMBDA) {
return apply(result, arg);
}
+ // if arguments left but result is not a lambda, explicitely return false TODO: return an error
+ if (arg->type == VT_PAIR) {
+ return make_nil();
+ }
return result;
}