properly macroExpand localFunction

This commit is contained in:
2024-02-17 12:39:36 -07:00
parent d5b14656f5
commit ac92346109
2 changed files with 22 additions and 3 deletions

View File

@@ -691,6 +691,11 @@ class SpecialForms {
b.callSymbol("let", [newBindings].concat(Lambda.map(args.slice(1), macroExpand)));
};
map["localFunction"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
var b = wholeExp.expBuilder();
b.callSymbol("localFunction", [expandTypeAliases(args[0])].concat(args.slice(1).map(macroExpand)));
};
return map;
}

View File

@@ -6,10 +6,16 @@
expanded ,(printExp (macroExpand expression))]
,@b))
(defMacro makeExampleNoValues [expression]
(defMacro makeExampleNoValues [expression &opt body1 body2]
`{
,(printExp expression)
,(printExp (macroExpand expression))
{
,(printExp expression)
,(or body1 `{})
}
{
,(printExp (macroExpand expression))
,(or body2 `{})
}
})
(function _testAllForms []
@@ -44,4 +50,12 @@
Stream (Stream.fromString "")]
null))
// localFunction
(makeExampleNoValues
(localFunction Stream [] (Stream.fromString "")))
(makeExampleNoValues
(localFunction :Stream s [] (Stream.fromString "")))
)