I am a bit confused about the function declaration order.
For example, if I write following module:
module A
function callzeros()
zeros(rand(5,5))
end
function callzeros2()
myzeros()
end
callzeros2()
function myzeros()
print("myzero")
end
function Base.zeros(like::Array{T}) where T<:Any
return zeros(size(like))
end
callzeros()
end
Then is the function callzeros going to recognized the my override? In general, does the function declaration order matter? If it does, is there any way get around this requirement like putting a function declaration in the header file in C++?
Can I clarify a little bit more: if I am overloading the same function with a slightly different type signatures in different submodules of a module, the order does not matter?
I am still a bit confused. In the example I gave, this module does not compile because myzeros is not recognized by callzeros2()
However, when you run code, then only the already-defined methods are available. Normally, you wouldn’t run code in a module (or you run it at the very end), so order does not matter.
Hmmm. Interesting… So the rule of thumb is that as long as I am doiing everything inside function definition(within the module), I don’t need to worry about the declaration order, right?