Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Multiple dispatch
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Use in practice === To estimate how often multiple dispatch is used in practice, Muschevici et al.<ref name=Muschevici>{{cite book |last1=Muschevici |first1=Radu |last2=Potanin |first2=Alex |last3=Tempero |first3=Ewan |last4=Noble |first4=James |title=Proceedings of the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications |chapter=Multiple dispatch in practice |year=2008 |series=OOPSLA '08 |pages=563β582 |doi=10.1145/1449764.1449808 |publisher=ACM |location=Nashville, TN, USA |isbn=9781605582153|s2cid=7605233 |url=https://figshare.com/articles/thesis/Multiple_Dispatch_in_Practice/16959112 }}</ref> studied programs that use dynamic dispatch. They analyzed nine applications, mostly compilers, written in six different languages: [[Common Lisp Object System]], [[Dylan (programming language)|Dylan]], [[Cecil (programming language)|Cecil]], MultiJava, Diesel, and Nice. Their results show that 13β32% of generic functions use the dynamic type of one argument, while 2.7β6.5% of them use the dynamic type of multiple arguments. The remaining 65β93% of generic functions have one concrete method (overrider), and thus are not considered to use the dynamic types of their arguments. Further, the study reports that 2β20% of generic functions had two and 3β6% had three concrete function implementations. The numbers decrease rapidly for functions with more concrete overriders. Multiple dispatch is used much more heavily in [[Julia (programming language)|Julia]], where multiple dispatch was a central design concept from the origin of the language: collecting the same statistics as Muschevici on the average number of methods per generic function, it was found that the Julia [[standard library]] uses more than double the amount of overloading than in the other languages analyzed by Muschevici, and more than 10 times in the case of [[Operator (computer programming)|binary operators]].<ref name=julia-review/> The data from these papers is summarized in the following table, where the dispatch ratio <code>DR</code> is the average number of methods per generic function; the choice ratio <code>CR</code> is the mean of the square of the number of methods (to better measure the frequency of functions with a large number of methods);<ref name=Muschevici/><ref name=julia-review/> and the degree of specialization <code>DoS</code> is the average number of type-specialized arguments per method (i.e., the number of arguments that are dispatched on): {| class="wikitable sortable" |- ! Language ! Average # methods (DR) ! Choice ratio (CR) ! Degree of specialization (DoS) |- | [[Cecil (programming language)|Cecil]]<ref name=Muschevici/> | 2.33 | 63.30 | 1.06 |- | [[Common Lisp]] ([[CMU Common Lisp|CMU]])<ref name=Muschevici/> | 2.03 | 6.34 | 1.17 |- | Common Lisp ([[McCLIM]])<ref name=Muschevici/> | 2.32 | 15.43 | 1.17 |- | Common Lisp ([[Steel Bank Common Lisp|Steel Bank]])<ref name=Muschevici/> | 2.37 | 26.57 | 1.11 |- | Diesel<ref name=Muschevici/> | 2.07 | 31.65 | 0.71 |- | [[Dylan (programming language)|Dylan]] (Gwydion)<ref name=Muschevici/> | 1.74 | 18.27 | 2.14 |- | Dylan (OpenDylan)<ref name=Muschevici/> | 2.51 | 43.84 | 1.23 |- | [[Julia (programming language)|Julia]]<ref name=julia-review/> | 5.86 | 51.44 | 1.54 |- | Julia (operators only)<ref name=julia-review/> | 28.13 | 78.06 | 2.01 |- | MultiJava<ref name=Muschevici/> | 1.50 | 8.92 | 1.02 |- | Nice<ref name=Muschevici/> | 1.36 | 3.46 | 0.33 |- |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)