From e2dff04ba89f3fd0f27283bc7fdfd3b94b950d8b Mon Sep 17 00:00:00 2001 From: Elijah Cohen Date: Mon, 12 Aug 2024 23:21:30 -0500 Subject: [PATCH] i fixed the problem of consing stuff evaluating weird... for now --- ideas.org | 11 +++++++++++ src/builtins/core.c | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) 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)) -- 2.39.2