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
Dynamic 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!
{{Short description|Selecting which implementation of a method or function to call at run time}} {{About|the selection of an implementation of a polymorphic operation |dynamic binding|Late binding}} {{use dmy dates|date=July 2022|cs1-dates=y}} {{use list-defined references|date=July 2022}} {{Polymorphism}} In [[computer science]], '''dynamic dispatch''' is the process of selecting which implementation of a [[Polymorphism (computer science)|polymorphic]] operation ([[Method (computer programming)|method]] or function) to call at [[Run time (program lifecycle phase)|run time]]. It is commonly employed in, and considered a prime characteristic of, [[object-oriented programming]] (OOP) languages and systems.<ref name="Milton-Schmidt_1994"/> Object-oriented systems model a problem as a set of interacting objects that enact operations referred to by name. Polymorphism is the phenomenon wherein somewhat interchangeable objects each expose an operation of the same name but possibly differing in behavior. As an example, a {{mono|File}} object and a {{mono|Database}} object both have a {{mono|StoreRecord}} method that can be used to write a personnel record to storage. Their implementations differ. A program holds a reference to an object which may be either a {{mono|File}} object or a {{mono|Database}} object. Which it is may have been determined by a run-time setting, and at this stage, the program may not know or care which. When the program calls {{mono|StoreRecord}} on the object, something needs to choose which behavior gets enacted. If one thinks of OOP as [[message passing|sending messages]] to objects, then in this example the program sends a {{mono|StoreRecord}} message to an object of unknown type, leaving it to the run-time support system to dispatch the message to the right object. The object enacts whichever behavior it implements.<ref name="Driesen-Hoelzle-Vitek_1995"/> Dynamic dispatch contrasts with ''[[static dispatch]]'', in which the implementation of a polymorphic operation is selected at [[compile time]]. The purpose of dynamic dispatch is to defer the selection of an appropriate implementation until the run time type of a parameter (or multiple parameters) is known. Dynamic dispatch is different from [[late binding]] (also known as dynamic binding). [[Name binding]] associates a name with an operation. A polymorphic operation has several implementations, all associated with the same name. Bindings can be made at compile time or (with late binding) at run time. With dynamic dispatch, one particular implementation of an operation is chosen at run time. While dynamic dispatch does not imply late binding, late binding does imply dynamic dispatch, since the implementation of a late-bound operation is not known until run time.{{fact|reason=This paragraph is confused and conflicts with most definitions|date=October 2018}}
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)