Re: Templates and imports

2020-02-26 Thread juancarlospaco
[https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates) Far from perfect, but better than nothing, Templates explanation.

Re: Templates and imports

2020-02-26 Thread Hlaaftana
use bind import strutils template test_template*() = bind formatFloat echo (1.0/3.0).formatFloat(precision=3) proc test_proc*() = echo (1.0/3.0).formatFloat(precision=3) Run

Re: Templates and imports

2020-02-26 Thread doofenstein
it works if you change the template: template test_template*() = echo formatFloat((1.0/3.0), precision=3) Run See

Re: Templates and imports

2020-02-26 Thread solo989
Your code works @treeform as long as you fix the typo in tempalte proc b() = echo "hi" template a*() = b() Run Inside template a, b is a sym,closedSymChoice or openSymChoice so it works regardless of whether or not b is private or not.

Re: Templates and imports

2020-02-26 Thread treeform
Hmm, I think it always worked like this. Template just substitute code. If the code where you have template can't access some thing... then it's an error. It also is an error if template calls a private proc: proc b() = # private b echo "hi" tempalte a*() = # public

Re: Templates and imports

2020-02-26 Thread solo989
It works if you define it like this: # test.nim import strutils template test_template*() = echo formatFloat(1.0/3.0,precision=3) #echo (1.0/3.0).formatFloat(precision=3) proc test_proc*() = echo (1.0/3.0).formatFloat(precision=3)

Templates and imports

2020-02-26 Thread c0ntribut0r
Hello folks, Does anyone know why templates don't "auto-import" symbols defined in their residence file? :( Minimal example: # test.nim import strutils template test_template*() = echo (1.0/3.0).formatFloat(precision=3) proc test_proc*() = echo