From: Elijah Cohen Date: Tue, 13 Aug 2024 04:21:30 +0000 (-0500) Subject: i fixed the problem of consing stuff evaluating weird... for now X-Git-Url: https://git.eli173.com/?a=commitdiff_plain;h=e2dff04ba89f3fd0f27283bc7fdfd3b94b950d8b;p=klapaucius i fixed the problem of consing stuff evaluating weird... for now --- diff --git a/ideas.org b/ideas.org index 9690f46..bbf6e65 100644 --- a/ideas.org +++ b/ideas.org @@ -1,3 +1,14 @@ +okay the problem: +(cons 1 (cons 2 nil)) +goes to (cons 1 (2)) +which evaluates down to +(cons 1 2) +which is +(1 . 2) +how do I get the expected result of (1 2)? + +I think I need to figure out how to properly abuse quotes? + so i'm redoing the basic eval to not pass an arg, but pass the rest of the list... yeah? then the builtins just harvest the rest one at a time to get all their args, diff --git a/src/builtins/core.c b/src/builtins/core.c index 99eb17c..03791a6 100644 --- a/src/builtins/core.c +++ b/src/builtins/core.c @@ -23,10 +23,15 @@ Sexpr* c_quote(Sexpr* b, Sexpr* rest, Sexpr* env) { Sexpr* c_cons(Sexpr* b, Sexpr* rest, Sexpr* env) { if(CORE_CONS_ARGS != u64_get_num_args(b)) return cons(b, rest); + // big problem: need to rewrite to wiggle around quotes Sexpr* args = b->value.b.args; Sexpr* _cdr = eval(car(args), env); + if(_cdr->type == QUOTE) + _cdr = _cdr->value.q; Sexpr* _car = eval(car(cdr(args)), env); - return cons(cons(_car, _cdr), rest); + if(_car->type == QUOTE) + _car = _car->value.q; + return cons(from_quote(cons(_car, _cdr)), rest); } Sexpr* c_car(Sexpr* b, Sexpr* rest, Sexpr* env) { if(CORE_CAR_ARGS != u64_get_num_args(b))