In a libarary I defined a template like so:
when isMainModule:
template test() {.immediate.} = echo(...)
...
when isMainModule:
test()
Everything works fine (i.e. sth. gets printed) when I compile the library as the main module. However, when I import said library to another program, test() gets executed too, something that I would not expect.
Is this a bug, or am I getting something wrong?
Just as a check: Do you "include" or "import" the library? They behave differently:
http://nim-lang.org/docs/tut1.html#modules-include-statement
I cant replicated this
a.nim:
proc test() =
echo "test"
when is_main_module:
test()
b.nim:
import a
with command nim c -r b.nim