summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-06-16 11:58:13 +0200
committerlemon <lsof@mailbox.org>2025-06-16 12:01:04 +0200
commitbd4fc32bace9ee9727243ddf59f0066d5aa5e0a4 (patch)
treede14b8461356923fce2c2a12d7f9b9f501ea8f9d
parentc2021ab74da2048fc330c8185d98f2c9331c8149 (diff)
repl: put last value in _
-rw-r--r--repl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/repl.c b/repl.c
index bf1e41e..7324b2f 100644
--- a/repl.c
+++ b/repl.c
@@ -75,12 +75,15 @@ main(int argc, char **argv) {
using_history();
CHECK(pez_pushglobal(cx, "printf"));
+ CHECK(pez_pushvoid(cx) && pez_setglobal(cx, "_"));
while ((src = readline("> "))) {
add_history(src);
if (!pez_eval_str(cx, "<repl>", src)) {
fprintf(stderr, "error: %s\n", pez_geterr(cx));
} else {
assert(pez_top(cx) == 2);
+ CHECK(pez_push(cx, -1));
+ CHECK(pez_setglobal(cx, "_"));
CHECK(printtop(cx));
printf("\n");
}