3 ms·
> Specificity is required to disambiguate between two or more methods which are all supertypes of the argument type. … The specificity rules are defined by the
by jpeloquin 6y ago
> Specificity is required to disambiguate between two or more methods which are all supertypes of the argument type. … The specificity rules are defined by the implementation and lack a formal semantics.
The lack of formal rules governing which method will be selected for a given set of arguments has made me somewhat reluctant to use Julia for large projects. Since everything in the language works off of multiple dispatch, it's a little disconcerting to have it governed by vague rules.
However, the manual [0] says that when two methods of equal specificity are present, "Julia raises a MethodError rather than arbitrarily picking a method". The manual doesn't discuss the 5 special cases in the linked PDF, though, as far as I can tell. So did the dispatch / specificity rules get formalized at some point? Or is concern about having formal rules governing dispatch unwarranted?
[0] https://docs.julialang.org/en/v1/manual/methods/ https://docs.julialang.org/en/v1/manual/methods/
- KenoFischer 6y agoThe subtyping system is fairly complicated, but in practice users only need to really think about situations where the LHS is a concrete type, since that's primarily what determines runtime semantics (not to say that there aren't situations where specificity really matters, but it's quite rare). That simplifies the mental model considerably and our users tend to find it relatively intuitive. For a formal discussion, the group at Northeastern has been doing great work in phrasing some of the Julia internals in more traditional PL language, including a formal subtyping model. That paper is at http://janvitek.org/pubs/oopsla18a.pdf http://janvitek.org/pubs/oopsla18a.pdf
- snicker7 6y agoLove JuliaLang. But it definitely comes across as a language defined by its implementation. It is poorly specified relative to most popular languages. Appreciate the work by the paper's authors, though.
- KenoFischer 6y agoI think that's observation is fair, but I would also argue it is neither unusual (e.g. Python doesn't have one and it's probably one of the most popular language on the planet at the moment) nor a bad thing. In programming language design, you need to implement things and try out how they feel to use in practice. Programming language design is mostly about interfacing with humans, not computers. Something that has a beatiful proof on paper, but feels clumsy to use is bad programming language design. Eventually one of the efforts to make Julia an ISO standard will win and we'll be doing language design by committee and have a formal specification, but until then we'll try to build the best language we can ;).
- deleted 6y ago[deleted]