From f5f261968de27ecdd2eacedc6255da115e7b43cb Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Fri, 12 Jan 2024 19:12:05 -0800 Subject: fix keep for real, can I keep on doing this forever? --- src/builtins.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/builtins.c b/src/builtins.c index a189060..a659171 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -556,6 +556,7 @@ void dip(value_t *v) { array_append(STACK, v1); } +/* 3 4 4 [ + ] keep */ void keep(value_t *v) { value_t *v2 = array_pop(STACK); if (v2 == NULL) { @@ -569,17 +570,16 @@ void keep(value_t *v) { return; } - array_append(STACK, value_copy(v1)); - if (v1->type == VQUOTE) { - array_append(EVAL_STACK, v1); - for (int i = 0; i < v1->quote->size; i++) { - eval(value_copy(v1->quote->items[i])); + if (v2->type == VQUOTE) { + array_append(EVAL_STACK, v2); + for (int i = 0; i < v2->quote->size; i++) { + eval(value_copy(v2->quote->items[i])); } value_free(array_pop(EVAL_STACK)); } else { - eval(v1); + eval(v2); } - array_append(STACK, v2); + array_append(STACK, v1); } void del(value_t *v) { -- cgit