diff options
| author | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2025-12-22 16:12:22 +0100 |
|---|---|---|
| committer | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2025-12-22 16:12:22 +0100 |
| commit | eaf6f03f1a572798dca70e897895560110703324 (patch) | |
| tree | 85f3c5440ac8d704212cc5beae0b7c4c8075dc49 | |
| parent | b43819ef8d2f7aca08c714392e9578f13e619d82 (diff) | |
improve symbol not found handling (copy pasteable quoting), use head_eval in eval return instead of evaluating a twice
| -rw-r--r-- | lisp.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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) { |
