Again, this would change the behavior of the function without actually touching its code. The general approach in literally every (non-esoteric) programming language I know is to minimize the perception border of the code you read or write. One way to do it is to keep control flow local, i.e. write code in small independent chunks that you can reason about without looking at any other place. Imagine, that you read somebody’s large module and see a function:
a = 2
What can you tell about
a? With Julia’s scoping rules you definitely know that
a is local, it doesn’t affect any global variables and this code doesn’t cause any warnings. From only 4 lines of code, you know exactly what will happen when you call this function. In addition, you can now introduce a global variable
a somewhere in the module without worrying to affect any of local variables.
With global variables, it becomes much harder to reason about the code because in this case you have to keep in mind all the code, not just a little piece.
In your case I’d create a struct to keep all parameters together and pass it to all functions. Something like:
mutable struct Params
function foo(p::Params, ...)
p.a = 2
type instead of
mutable struct if you are on Julia 0.5)
This way you need just a bit more keystrokes, but code maintainability increases drastically.