macroExpand for/doFor

This commit is contained in:
2024-02-17 12:47:47 -07:00
parent ac92346109
commit d78f103e9a
2 changed files with 23 additions and 0 deletions

View File

@@ -696,6 +696,16 @@ class SpecialForms {
b.callSymbol("localFunction", [expandTypeAliases(args[0])].concat(args.slice(1).map(macroExpand)));
};
function forExpander (keyword:String) {
map[keyword] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
var b = wholeExp.expBuilder();
b.callSymbol(keyword, [expandTypeAliases(args[0])].concat(args.slice(1).map(macroExpand)));
};
}
forExpander("for");
forExpander("doFor");
return map;
}

View File

@@ -57,5 +57,18 @@
(makeExampleNoValues
(localFunction :Stream s [] (Stream.fromString "")))
// for/doFor
(localVar listOfLists [["a b c"]["d e f"]])
(defAlias &ident lol listOfLists)
(defAlias &type Texty String)
(makeExampleNoValues
(for [:Texty t1 :Texty t2 :Texty t3] lol
null))
(makeExampleNoValues
(doFor [:Texty t1 :Texty t2 :Texty t3] lol
null))
)