It's hard to imagine what real lisp-like macros look like with other, non-homoiconic langauges. Anyone have an example?
template htmlTag(tag: expr) {.immediate.} =
proc tag(): string = "<" & astToStr(tag) & ">"
htmlTag(br)
htmlTag(html)
echo br()
produces: <br>
http://nimrod-lang.org/talk01/slides.htmlThe macros run at compile-time, and emit code by use of the <[ ]> blocks -- those get turned into ASTs at compile-time and get filled with the proper data.
http://docs.julialang.org/en/release-0.2/manual/metaprogramm...
You end up being able to reify the entire Haskell syntax tree from "quoted" fragments, manipulate and generate a modified tree, and then "print" it back into program flow.
Totally capable, but not terrifically fun. It also has some compilation restrictions which are annoying if necessary.
https://github.com/dlthomas/snowdrift/compare/5094b1ca0e5002...