From eaf6f03f1a572798dca70e897895560110703324 Mon Sep 17 00:00:00 2001 From: Felix Perktold Date: Mon, 22 Dec 2025 16:12:22 +0100 Subject: improve symbol not found handling (copy pasteable quoting), use head_eval in eval return instead of evaluating a twice --- lisp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp.c b/lisp.c index dca63ad..df84b6f 100644 --- a/lisp.c +++ b/lisp.c @@ -217,7 +217,8 @@ value *eval(env *e, value *v) { value *found = env_lookup(e, v->as.sym); if (!found) { printf("symbol %s not found\n", v->as.sym); - return make_nil(); + return cons(make_symbol("quote"), + cons(v, make_nil())); } return found; } @@ -287,7 +288,7 @@ value *eval_pair(env *e, value *v) { } // else evaluate the list recursively - return cons(eval(e, car(v)), eval(e, cdr(v))); + return cons(head_eval, eval(e, cdr(v))); } value *apply(value *lval, value *args) { -- cgit v1.2.3