is it possible to set a gloabal varaibes from a procure whicvh shadows thos global varaible?
My use case:
var verbose = false
proc a() =
# Uses verbose
proc b() =
# Uses verbose
proc main(verbose, ...) =
(global) verbose = verbose
a()
b())
I'm asking this because I'm using cligen as the cli parser and my option is meant to be called --verbose on the comamd line.
Easiest solution is to call the global variable chatty and be done wioth teh shadowing, but now I', curious whether I Nim ahs a mechanism for this.
Something like this works:
var verbose = false
template globalVerbose: untyped =
bind verbose
verbose
proc foo(verbose: bool) =
globalVerbose = true
foo(false)
echo verbose