Single Dispatch is an actively used design pattern. When the type of a single object is enough to determine what method to call.

?Years Old
  • Have a question about Single Dispatch not answered here? Email me and let me know how I can help.
  • Read more about Single Dispatch

Languages with Single Dispatch include common-lisp, cpp, java, javascript, objective-c, python, swift

Example from common-lisp:

(defclass Person () ())
(defmethod frobnicate ((p Person) record spreadsheet)
 (format t "~a ~a ~a~&" (type-of p) (type-of record) (type-of spreadsheet)))
(defclass Asteroid () ())
(defmethod frobnicate ((a Asteroid) velocity size)
 ; do stuff
; At runtime these 2 would be routed to respective methods:
(frobnicate a-person his-record big-spreadsheet)
(frobnicate an-asteroid very-fast pretty-small)

Last updated June 22nd, 2020

Edit Single Dispatch on GitHub