Re: template - body issue

2020-03-26 Thread jyapayne
Use `expandMacros`, like below:


import macros

template tpl(name: untyped, body: untyped): untyped =
  proc `name Free`()=
body

expandMacros:
  tpl(myname):
echo "1"
echo "2"

mynameFree()


Run


Re: template - body issue

2020-03-26 Thread mantielero
One remaning question is how can I see the result from a template execution. I 
am not talking about invoking the template. For instance in the example above, 
is there a way to see how:


tpl(myname):
   echo "1"
   echo "2"

Run

gets converted into:


proc mynameFree() =
   echo "1"
   echo "2"

Run


Re: template - body issue

2020-03-25 Thread doofenstein
instead of a string use untyped, i.e. 


template tpl(name:untyped, body:untyped):untyped =
proc `name Free`()=
body

tpl(myname):
echo "1"
echo "2"

mynameFree()


Run