- Source: Static dispatch
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.
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.
Example in Rust
In Rust.
Rust will monomorphize this when compiled into:
See also
Dynamic dispatch
References
https://developer.apple.com/swift/blog/?id=27
Kata Kunci Pencarian:
- Bloody Heart
- TV Tokyo
- Static dispatch
- Dynamic dispatch
- Multiple dispatch
- Polymorphism (computer science)
- Inheritance (object-oriented programming)
- Virtual inheritance
- Fragile base class
- Generic function
- Rust (programming language)
- Virtual function