@Pmunch hIf I may- even if I don't end up using it exactly in the way I 
imagined, I'd love to learn more about your approach to statically finding 
procedure calls in a code block. I might still ignore all expert advice ;) and 
go for rollback/commit autodetection after all, but even if I don't, I'd love 
to be able to warn users if, for example, there are no writes operations in a 
write transaction. I there's the effect system, but I want to do without 
experimental features.

Your approach using a `compileTime` variable seemed compelling. I was playing 
with it a little but I'm not sure what else to try in figuring out how to 
statically track the use of a proc. Any other approach would also be very 
welcome. Thanks!
    
    
    # This is my first attempt to use a compileTime var
    # It should output 'not called - called' at compile time, but it actually 
does output 'not called - not called' at runtime.
    var called {.compileTime} = false
    
    template wasItCalled(body: typed) =
      static:
        called = false
      body
      static:
        when called:
          echo "called"
        else:
          echo " not called"
    
    
    proc rawFoo() =
      discard
    
    template foo() =
      static:
        called = true
      discard
    
    wasItCalled:
      discard
      # This should echo 'not called'
    
    wasItCalled:
      foo()
      # This sould echo 'called'
    
    
    Run

Reply via email to