`def` can bind multiple vars at once

For example `(def (a b) (10 15))` binds `a` to 10, and `b` to 15
This commit is contained in:
Sage Vaillancourt 2020-11-02 13:42:37 -05:00
parent 3319fdf2c3
commit 058bd302df
1 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,15 @@ Object evalDefArgs(const Object *argForms, struct Environment *env)
const Object *newSymbol = argForms; const Object *newSymbol = argForms;
const char *name = newSymbol->string; 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); Object newValue = eval(newSymbol->forward, env);
addToEnv(env, name, newValue); addToEnv(env, name, newValue);