ExpBuilder.when/unless

This commit is contained in:
2024-11-26 16:40:28 -06:00
parent f78d25233a
commit a4fbf27891

View File

@@ -54,6 +54,9 @@ class ExpBuilder {
callSymbol("kiss.Prelude.runtimeInsertAssertionMessage", [messageExp, str(failureError), int(colonsInPrefix)])
]);
}
function whenUnless(which:String, condition:ReaderExp, body:Array<ReaderExp>) {
return callSymbol(which, [condition].concat(body));
}
return {
call: call,
callSymbol: callSymbol,
@@ -74,6 +77,8 @@ class ExpBuilder {
keyValue: (key:ReaderExp, value:ReaderExp) -> KeyValueExp(key, value).withPosOf(posRef),
begin: (exps:Array<ReaderExp>) -> callSymbol("begin", exps),
set: (v:ReaderExp, value:ReaderExp) -> callSymbol("set", [v, value]),
when: whenUnless.bind("when"),
unless: whenUnless.bind("unless"),
let: let,
objectWith: objectWith,
expFromDef: (def:ReaderExpDef) -> def.withPosOf(posRef),