Measures Concepts
GitHub icon

Multiple Dispatch

Multiple Dispatch - language feature

< >
Example from Julia:
collide_with(x::Asteroid, y::Asteroid) = ... # deal with asteroid hitting asteroid collide_with(x::Asteroid, y::Spaceship) = ... # deal with asteroid hitting spaceship collide_with(x::Spaceship, y::Asteroid) = ... # deal with spaceship hitting asteroid collide_with(x::Spaceship, y::Spaceship) = ... # deal with spaceship hitting spaceship
Example from Common Lisp:
(defmethod collide-with ((x asteroid) (y asteroid)) ;; deal with asteroid hitting asteroid ) (defmethod collide-with ((x asteroid) (y spaceship)) ;; deal with asteroid hitting spaceship ) (defmethod collide-with ((x spaceship) (y asteroid)) ;; deal with spaceship hitting asteroid ) (defmethod collide-with ((x spaceship) (y spaceship)) ;; deal with spaceship hitting spaceship )

Languages with Multiple Dispatch include Julia, Smalltalk, Common Lisp, Dylan

Languages without Multiple Dispatch include JavaScript, TypeScript, Elixir, Speedie

This question asks: Does the language support multiple dispatch?

Read more about Multiple Dispatch on the web: 1.

HTML of this page generated by Features.ts

View source

- Build the next great programming language Search Add Language Features Creators Resources About Blog Acknowledgements Queries Stats Sponsor Day 605 feedback@pldb.io Logout