You could use a define: Have this in all your files:
const samplerate {.intdefine.} = 0
Then set them all with -d:samplerate=100 for example.
You say "used by all included libraries", I assume you meant imported, but in case you actually meant included you just need to specify the variable before the include:
const samplerate = 100
include othermodule # This will now have `samplerate` available
Other than that I thing you just have to have a globals.nim module where you can set all your globals and then import this module everywhere.
What is your usecase for this, though? Why would an object not suffice? It's what I'd prefer personally, but if your usecase requires a global, that's understandable
Though if it's a mutable global value, you may have issues if you ever use threading and such
"used by all included libraries"
Hah, three decades of POV-Ray shows, libraries are include files.
I wasn't aware of Nim's include, can be useful but I'll try with const samplerate {.intdefine.} = 0 first and add the -d:samplerate=100 to the nim.cfg
Thanks.
What is your usecase for this, though?
I'm writing a little additive synth. In some libraries there are some stray functions that need a sample rate set. There are a few objects that need a samplerate set but that don't inherit from or build upon each other. When creating textures/patterns for sound at an other samplerate I've to go through these libraries by hand. For now, once it all works and is tidied up an other way me be better.