type
      TextCache = ref object
    
    var cnt = 0
    
    proc newTc(): TextCache =
      inc cnt
      result = TextCache()
    
    proc use(tc: TextCache) = discard
    
    template renderTextCached(text: string) =
      block:
        var tc {.global.} = newTc()
        use(tc)
    
    proc main =
      for x in 0..5:
        renderTextCached("hi")
    
    main()
    echo cnt
    
    
    Run

Outputs 1 with `refc`, 6 with ARC/ORC - each time a new variable is created.

Reply via email to