The title is the last sentence from the
[https://nim-lang.org/docs/tut2.html#templates](https://nim-lang.org/docs/tut2.html#templates)
and it refers to the following snippet of code:
template withFile(f: untyped, filename: string, mode: FileMode,
body: untyped): typed =
let fn = filename
var f: File
if open(f, fn, mode):
try:
body
finally:
close(f)
else:
quit("cannot open: " & fn)
withFile(txt, "ttempl3.txt", fmWrite):
txt.writeLine("line 1")
txt.writeLine("line 2")
Run
I can see `fn` is used in `if open(f, fn, mode):` and in `quit("cannot open: "
& fn)`. But why would it be evaluated twice if we did not use `let`? Aren't
arguments for template immutable?