From 988d4d665202450469a6ffea7c130962e17721f2 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 2 Aug 2022 15:27:54 +0000 Subject: [PATCH] very useful macroPrint keyword --- kiss/src/kiss/SpecialForms.hx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kiss/src/kiss/SpecialForms.hx b/kiss/src/kiss/SpecialForms.hx index e5177e75..58d6cf48 100644 --- a/kiss/src/kiss/SpecialForms.hx +++ b/kiss/src/kiss/SpecialForms.hx @@ -493,6 +493,18 @@ class SpecialForms { ]).withMacroPosOf(wholeExp); }; + k.doc("macroPrint", 1, 1, "(macroPrint )"); + // At compile-time, print the macro expansion and generated haxe code of the given expression, + // Then at runtime, evaluate the expression normally. + map["macroPrint"] = (wholeExp:ReaderExp, exps:Array, k:KissState) -> { + var b = wholeExp.expBuilder(); + Helpers.printExp(exps[0]); + + var e = Kiss.convert(k, exps[0]); + Prelude.printStr(e.toString()); + return e; + }; + return map; }