genericsOpenSym: 
<https://github.com/nim-lang/Nim/blob/devel/changelog.md#language-changes>

I think this new feature is great. However I don't understand this behaviour:
    
    
    {.experimental: "genericsOpenSym".}
    
    let hi = "captured"
    
    template foo(x: int, body: untyped) =
      let hi {.used, inject.} = "injected"
      body
    
    proc test1[T]() =
      foo(123):
        echo hi
    
    proc test2[T]() =
      bind hi
      foo(123):
        echo hi
    
    test1[int]()
    test2[int]()
    
    # output:
    # injected
    # captured
    
    
    Run
    
    
    {.experimental: "genericsOpenSym".}
    
    let hi = "captured"
    
    template foo(body: untyped) =
      let hi {.used, inject.} = "injected"
      body
    
    proc test1[T]() =
      foo():
        echo hi
    
    proc test2[T]() =
      bind hi
      foo():
        echo hi
    
    test1[int]()
    test2[int]()
    
    # output:
    # injected
    # injected
    
    
    Run

Shouldn't be the output same?

Reply via email to