I just fell into the same trap as @DrKrar.
For my simulation I need to read few performance critical parameters from a file once in the beginning which will be constant throughout the simulation. I intended to use
consts for that, since the docs stated that only changing the type of a
const raises an error and the meaning of the warning was somewhat vague. I have outlined two potential strategies I could use:
“Dirty” way with warnings
module A "prominent documentation for x" const x = dummy export x function init() global const x=readonce() #sets actual value, causes warnings ... end end module B import A: x # selective imports are great ...do something with x... end
module A function init() "this will not generate documentation for x ?!" global const x = readonce() end end module B using A: x # UndefVarError, if A.init() not called yet ... end module C using A # works ... end
The correct way of course works (except for the documentation not being generated, bug or feature?), but reduces the readability of the code. I’d like to have important variables defined at a prominent position instead of popping up in the middle of some function. Is there any preferred way to deal with such situations?