It works when the macro parameter is untyped, I guess constant folding happens
during the typing process:
import macros
macro mylog(x:untyped): untyped =
result = newNimNode(nnkStmtList, x)
result.add(newCall("write", newIdentNode("stdout"), toStrLit(x)))
Oh, right! I guess it's testing it on untyped rather than the actual type in
the macro. Anyways, this one is definitely working, it just tests for
void-typed arguments:
import macros
import typetraits
import strformat
macro fun*(n: varargs[typed]): typed =
Thanks for the suggestions.
@mratsim I had no idea you could put a template inside a macro and get its
evaluated AST. Cool! This will be very useful.
@Lando Interesting, I guess this works because quote doesn't touch the passed
in backticked identifier and this is then returned intact to the
Yes, that compiles, but the macro produces the code
let x = 1000
instead of the code
let xExtra = 1000
I'm trying to get the identifier to be constructed before passing it into the
macro, but I'm not sure if that's possible.
I have a macro that creates a type and associated functions, and I'm calling
that from a template. I want to use identifier construction to append a suffix
to the template parameter, but the whole backticked AST (instead of the
constructed identifier) gets passed in to the macro. Is there some
@yglukhov Thanks, that makes sense, I can just call GC_step at the start of
each emscripten_set_main_loop callback. By the way, thanks for writing jsbind,
it has been very helpful!
@mashingan I copied most of the nim.cfg from here:
I've been using Nim to generate WebAssembly using Emscripten and everything
seems to be working very well. Are there any special considerations I should
make for the GC? I know that it's impossible to scan the stack in WASM, but
that shouldn't be much of a problem for Nim due to reference