I guess it's just semantically not how Nim works.

A proc has 1 body. However, if you use static/generic parameters then different 
versions of the proc body will be generated at compile-time based on the input.
    
    
    proc say(n: static int) =
      when n == 1:
        echo "static one!"
      else:
        echo "static " & $n
    
    proc say(n: int) =
      echo "dynamic " & $n
    
    var x = 3
    
    say(1)     # --> static one!
    say(2)     # --> static 2
    say(x)     # --> dynamic 3
    
    
    Run

(under the hood I believe 3 different procedures will be generated here, two of 
them are different variations of the first proc)

But you can't implement your factorial example with this, because choosing 
whether to return '0' or 'n*fac(n-1)' is a runtime decision.

Reply via email to