From 058bd302dfb63b54e877afb45912f4795da30048 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 2 Nov 2020 13:42:37 -0500 Subject: [PATCH] `def` can bind multiple vars at once For example `(def (a b) (10 15))` binds `a` to 10, and `b` to 15 --- src/pebblisp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pebblisp.c b/src/pebblisp.c index 075b78e..5ba62a0 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -14,6 +14,15 @@ Object evalDefArgs(const Object *argForms, struct Environment *env) const Object *newSymbol = argForms; const char *name = newSymbol->string; + if(argForms->type == TYPE_LIST && argForms->forward->type == TYPE_LIST) { + FOR_POINTERS_IN_LISTS(argForms, argForms->forward) { + Object newValue = eval(P2, env); + addToEnv(env, P1->string, newValue); + cleanObject(&newValue); + } + return cloneObject(*newSymbol); + } + Object newValue = eval(newSymbol->forward, env); addToEnv(env, name, newValue);