macroExpand cast

This commit is contained in:
2024-02-17 13:28:39 -07:00
parent 1e887693ea
commit efbd024c3f
2 changed files with 16 additions and 1 deletions

View File

@@ -713,6 +713,18 @@ class SpecialForms {
b.callSymbol("the", [Helpers.expandTypeSymbol(args[0], k), macroExpand(args[1])]);
};
map["cast"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
var b = wholeExp.expBuilder();
var newArgs = [macroExpand(args[0])];
if (args.length == 2) {
newArgs.push(Helpers.expandTypeSymbol(args[1], k));
}
b.callSymbol("cast", newArgs);
};
return map;
}

View File

@@ -76,5 +76,8 @@
.content (the Stream (Stream.fromString "hey"))
(Assert.equals normal "hey\n")
(Assert.equals expanded "hey\n"))
(makeExample
.content (cast (Stream.fromString "hey") Stream)
(Assert.equals normal "hey\n")
(Assert.equals expanded "hey\n"))
)