proc p(i: int): int {.noSideEffect.} =
debugEcho("p() called")
return i * 2
proc p2 =
echo p(3)
echo 2 * p(3)
p2()
./t
p() called
6
p() called
12
I was always hoping that above code would call proc p() only once, as p has no side effects and is called two times with same parameter. So caching result should occur.