Skip to content

Instantly share code, notes, and snippets.

@ReneSac
Last active August 29, 2015 13:56
Show Gist options
  • Save ReneSac/715730359e06c472f683 to your computer and use it in GitHub Desktop.
Save ReneSac/715730359e06c472f683 to your computer and use it in GitHub Desktop.
# Works:
template timeit*(code: stmt): float =
var sw = StopWatchInit()
code
sw.peek
echo timeit do:
swtest()
# Fails:
template timeit*(code: stmt): float =
timeit(0,3,code)
template timeit*(number: int = 0, repeat: int = 3, code: stmt): float =
var sw = StopWatchInit()
code
sw.peek
echo timeit do: # Info: instantiation from here
swtest() # Error: expression 'swtest()' has no type (or is ambiguous)
# Works:
echo timeit(0,3) do:
swtest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment