encyclopegia.org

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.

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. ==Examples== Consider the following Rust program: trait Pet { fn speak(&self); } struct Cat { name: String } impl Cat { fn new(name: String) -> Self { Cat { name } } } impl Pet for Cat { fn speak(&self) { println!("{} says Meow!", self.name); } } fn talk (pet: T) { pet.speak(); } fn main() { let pet = Cat::new(String::from("Simba")); talk(pet); } the Rust Compiler will monomorphize the program's code at compile time into: // [...] // struct Cat, Cat's impl, the Pet impl for struct Cat, and the Pet trait remain the same. fn talk_cat(pet: Cat) { Cat::speak(&pet) } fn main() { let pet = Cat::new(String::from("Simba")); talk_cat(pet); // talk(pet) gets replaced with the more specialized talk_cat } ==References== https://developer.apple.com/swift/blog/?id=27

References

No reference rows published for this article.

Cite this article

MLA

"Static dispatch." encyclopegia.org, 2026, https://encyclopegia.org/wiki/static-dispatch. Accessed 24 November 2026.

Chicago

"Static dispatch." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/static-dispatch.

APA

encyclopegia.org. (2026). Static dispatch. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/static-dispatch

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Pine-Strawberry Elementary School District

enwiki · references available

Oneonta City School District

enwiki · references available

Jessieville School District

enwiki · references available

Oracle Elementary School District

enwiki · references available

Piano Concerto No. 3 (Ohzawa)

enwiki · references available

Conscious business

enwiki · references available

Karl-Rüdiger Mann

enwiki · references available

Ruth Ann Gaines

enwiki · references available

Miguel de Horna

enwiki · references available

Locust Valley High School

enwiki · references available

Donguz (river)

enwiki · references available

El Debate (Mexico)

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1355364761 · 0.5 · snapshot enwiki-001355364761

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.