When you generate functions at runtime, the variables inside the function are 
from the closure around it. What I want is to dynamically generate something 
that becomes constant inside the function.

The code explains it way better:
    
    
    var test: seq[proc ()]
    
    for i in 0..5:
      test.add(
        proc () =
          echo i
      )
    
    test[3]() # I want it to echo 3, not 5
    
    
    Run

[https://play.nim-lang.org/#ix=2lfC](https://play.nim-lang.org/#ix=2lfC)

(And in case someone is wondering, yes I really do need this, just trust me the 
whole story is long and complicated)

Reply via email to