Revert "experimenting with builtin def, to be reverted"

This reverts commit 3821788983.
This commit is contained in:
NunoSempere 2023-05-07 17:00:00 -04:00
parent 3821788983
commit d338423ce3
2 changed files with 7 additions and 3 deletions

BIN
mumble

Binary file not shown.

View File

@ -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_ASSERT(v->count == 2, "Error: function def passed something other than 2 arguments");
lispval* symbols = v->cell[0]; 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->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++) { 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 } "); 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) if (VERBOSE)
print_lispval_tree(symbols, 0); print_lispval_tree(symbols, 0);
if (VERBOSE) if (VERBOSE)
print_lispval_tree(v->cell[i+1], 0); print_lispval_tree(values, 0);
if (VERBOSE) if (VERBOSE)
printf("\n"); 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(); // () return lispval_sexpr(); // ()
} }