Files
Nim/tests/showoff/tonce.nim
2014-01-13 01:05:09 +01:00

23 lines
299 B
Nim

discard """
output: '''first call of p
some call of p
new instantiation
some call of p'''
"""
template once(body: stmt) =
var x {.global.} = false
if not x:
x = true
body
proc p() =
once:
echo "first call of p"
echo "some call of p"
p()
once:
echo "new instantiation"
p()