[nim-dev] Re: template and block

  • From: JamesWirth <jwirth1@xxxxxxxxxxxxxx>
  • To: nim-dev@xxxxxxxxxxxxx
  • Date: Mon, 9 Nov 2015 16:56:24 +0000

Thanx LMB for the question and Jehan for the answer.

But I wonder why the block: statement inside this template

::
template hider(msg:expr,body:stmt) =
echo(msg)
block:
body

is seemingly elided from instantiations of the hider.

The {.immediate.} pragma DOES solve the problem - but I now wonder what other
alterations are performed on the body parameter before insertion into the
instantiation.

Here is the rest of the code exhibiting this phenomenon

::
var x=1
hider("one"):
var x=3
echo(x)
hider("two"):
var x=4
echo(x)


Yeah! Nim is inNimitable !!!



Other related posts: