mumble

A Lisp written in C, following the *Build Your Own Lisp* book
Log | Files | Refs | README

commit d338423ce3e6fbbd7398bbafd678e6d5243da5be
parent 382178898307d7eadd42c7aa06aae5f6edec4bc1
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sun,  7 May 2023 17:00:00 -0400

Revert "experimenting with builtin def, to be reverted"

This reverts commit 382178898307d7eadd42c7aa06aae5f6edec4bc1.

Diffstat:
Mmumble | 0
Msrc/mumble.c | 10+++++++---
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/mumble b/mumble Binary files differ. diff --git a/src/mumble.c b/src/mumble.c @@ -737,19 +737,23 @@ lispval* builtin_def(lispval* v, lispenv* env) LISPVAL_ASSERT(v->count == 2, "Error: function def passed something other than 2 arguments"); lispval* symbols = v->cell[0]; + lispval* values = v->cell[1]; + symbols = evaluate_lispval(symbols, env); + values = evaluate_lispval(values, env); LISPVAL_ASSERT(symbols->type == LISPVAL_QEXPR, "Error: Argument passed to def is not a q-expr, i.e., a bracketed list."); - LISPVAL_ASSERT(symbols->count == v->count-1, "Error: In function \"def\" both subarguments should have the same length"); + LISPVAL_ASSERT(values->type == LISPVAL_QEXPR, "Error: Argument passed to def is not a q-expr, i.e., a bracketed list."); + LISPVAL_ASSERT(symbols->count == values->count, "Error: In function \"def\" both subarguments should have the same length"); for (int i = 0; i < symbols->count; i++) { LISPVAL_ASSERT(symbols->cell[i]->type == LISPVAL_SYM, "Error: in function def, the first list of items should be of type symbol: def { a b } { 1 2 } "); if (VERBOSE) print_lispval_tree(symbols, 0); if (VERBOSE) - print_lispval_tree(v->cell[i+1], 0); + print_lispval_tree(values, 0); if (VERBOSE) printf("\n"); - insert_in_current_lispenv(symbols->cell[i]->sym, v->cell[i+1], env); + insert_in_current_lispenv(symbols->cell[i]->sym, values->cell[i], env); } return lispval_sexpr(); // () }