Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Single Dispatch

Single Dispatch

Single Dispatch is a feature.

When the type of a single object is enough to determine what method to call.

Languages with Single Dispatch include Java, JavaScript, Python, C++, Swift, Elixir, Objective-C, Common Lisp

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)
semantic-indentation-feature.html 路 single-dispatch-feature.html 路 single-type-arrays-feature.html

View source

PLDB - Build the next great programming language 路 v2022 Day 33 Docs Build Acknowledgements Traffic Today Traffic Trends Mirrors GitHub