Hi, I am learning Julialang on Mac and Windwos.
I have a question about the order of multiple dispatch.
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.
I look forward to your kind advice.
The order doesn’t matter. The method with the most specific signature that matches the argument types will be used.
Thank you very much your advice.
I understood that multiple dispatch is managed by signature.
If you know the location of the relevant Julia source code, could you let me know?
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.)
Thank you a lot of advice.
I try to read suggestions source code.
Thank you very much for your message.
I try to understand the docs.
I found “defining and adding methods” in method.c.
I will try to understand signeture system from here.
Thanks a lot.
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?
Thank you for your advices.
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.
Nice! If you’re interested in how method specificity is defined, look at the functions with
morespecific in their names in src/subtype.c.
Thank you very much for good information.
I will check Slack.
I will check src/subtype.c
Thanks a lot.