Hi, I am learning Julialang on Mac and Windwos.
I have a question about the order of multiple dispatch.
function dfunc(args::Int64)
println(“Int64”)
end
function dfunc(args::Any)
println(“Any”)
end
julia> dfunc(255)
Int64
julia> dfunc(“Test”)
Any
Yes,These functions work as expected.
However, is the order in which they are evaluated clearly defined?
My question is whether we don’t need to worry about Int64 being evaluated by Any.
Dispatch is handled by a pretty low-level part of the Julia implementation; reading through the dispatch code is not something likely to be helpful for someone just starting to learn Julia.
(There are plenty of other parts of Julia that are implemented in Julia with very readable code that it is informative to read. e.g. the complex-number implementation.)
Are you planning on learning Julia by reading the C source? That’s impressive and/or borderline crazy😁
I’ve never read any of the C source, and never will. If you are going on a real deep dive, I’m sure it will be a fascinating read, but are you confident that this is the right order? Why not start with the documentation instead?
Creating languages for myself and playing bass guitar are two of my hobbies.
C is an easy language for me to understand, as I’ve been using it for work since the 8-bit days.
I’ll make an effort to read a lot of documentation as you suggest.
I this. If you have any questions about the source code, feel free to ask on the JuliaLang Slack #internals channel, although you can also ask here but Slack may be more immediate and interactive.