From eaa0ad227969429b333d6ef26e4f4c9f266fbee5 Mon Sep 17 00:00:00 2001 From: Felix Perktold Date: Thu, 22 Jan 2026 00:23:18 +0100 Subject: changed the repl so defined values don't immediately get evaluated from REPL (important for endless lists etc) --- lisp.y | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lisp.y') diff --git a/lisp.y b/lisp.y index ec246f3..504e50f 100644 --- a/lisp.y +++ b/lisp.y @@ -1,6 +1,7 @@ %{ #include #include +#include #include "lisp_api.h" #include "lisp.h" @@ -9,9 +10,14 @@ int yyerror(const char *s); void eval_and_print_REPL(value *v) { if(!v) { return; } - value *ve = eval(global_env, v); + if (v->type == VT_PAIR && car(v)->type == VT_SYMBOL && !strcmp(car(v)->as.sym, "define")) { + eval(global_env, v); + printf(";> defined "); + println_value(car(cdr(v))); + return; // Skip printing for define so infinite lists do not eval + } printf(";> "); - println_value(ve); + println_value(eval(global_env, v)); } %} -- cgit v1.2.3