During compilation, selecting which implementation of a method or function to use
This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Static dispatch" – news · newspapers · books · scholar · JSTOR(January 2021) (Learn how and when to remove this message)
Polymorphism
Ad hoc polymorphism
Function overloading
Operator overloading
Parametric polymorphism
Generic function
Generic programming
Subtyping
Virtual function
Single and dynamic dispatch
Double dispatch
Multiple dispatch
Predicate dispatch
v
t
e
In computing, static dispatch is a form of polymorphism fully resolved during compile time. It is a form of method dispatch, which describes how a language or environment will select which implementation of a method or function to use.[1]
Examples are templates in C++, and generic programming in Fortran and other languages, in conjunction with function overloading (including operator overloading). Code is said to be monomorphised, with specific data types deduced and traced through the call graph, in order to instantiate specific versions of generic functions, and select specific function calls based on the supplied definitions.
This contrasts with dynamic dispatch, which is based on runtime information (such as vtable pointers and other forms of run time type information).
Static dispatch is possible because there is a guarantee of there only ever being a single implementation of the method in question. Static dispatch is typically faster than dynamic dispatch which by nature has higher overhead.
^Elements of Clojure. Lulu.com. 2019. p. 68. ISBN 9780359360581. Retrieved 17 July 2022.
In computing, staticdispatch is a form of polymorphism fully resolved during compile time. It is a form of method dispatch, which describes how a language...
binding and offers both dynamic and staticdispatch. The default form of dispatch is static. To get dynamic dispatch the programmer must declare a method...
Dynamic dispatch to CollideWith method class ColliderLibrary { public static string CollideWith(Asteroid x, Asteroid y) => "a/a"; public static string...
uniform syntax for both pointers and objects but also allows for staticdispatch, so it would arguably be the preferable method. In this case, the double...
In statically typed languages (such as C++ and Java), the term generic functions refers to a mechanism for compile-time polymorphism (staticdispatch),...
recursion (dynamic dispatch of methods on this), with the suggestion that invoking methods on this default to closed recursion (staticdispatch, early binding)...
contexts, the situation can be more complex, particularly in relation to staticdispatch. If an object of type Wolf is created but pointed to by an Animal pointer...
provides dynamic typing of 'static types. The choice between static and dynamic typing requires certain trade-offs. Static typing can find type errors...
either statically resolved, not via dynamic dispatch, or their memory statically allocated at compile time (once for the entire class, as static variables)...
with virtual method dispatching. This is why these languages strictly implement extension methods statically and use staticdispatching to invoke them. Extension...
A static line is a fixed cord attached to a large, stable object. It is used to open parachutes automatically for paratroopers and novice parachutists...
class A { public static $word = "hello"; public static function hello() { print static::$word; } } class B extends A { public static $word = "bye"; }...
the object's method table and so can statically calculate the offset. In a language supporting double dispatch, this is slightly more costly, because...
strongly, statically typed, or, even more confusingly, to mean simply statically typed. Thus C has been called both strongly typed and weakly, statically typed...
the instance reference as input, and implements the goal through double dispatch. Programming languages with sum types and pattern matching obviate many...
loop and dispatch of events/messages is handled by the framework or the runtime environment. In web server application frameworks, dispatch is usually...