A variable declared outside a function is recognized inside a function without actually passing it as an argument to it. For e.g. the script below runs perfectly.
const y = 3
function operate(x)
println(x^2+y)
end
operate(5)
Is it recommended to use global variables this way without actually passing them to the function? I would prefer to do something like this instead because of better readability:
const y = 3
function operate(x,z)
println(x^2+z)
end
operate(5,y)
Which way is more preferred? I understand that for this MWE there is no performance difference, but does the two approaches lead to any significant performance differences for large & complicated functions?