Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Predicate Dispatch

Tags:

I have seen much talk about predicate dispatch in Clojure lately and wonder if there is something to this thing. In other words, what is predicate dispatch and how does it differ from generic functions, OOP polymorphism, and patterns? Thank you

like image 293
Eli Schneider Avatar asked Apr 15 '11 01:04

Eli Schneider


People also ask

What is predicate in OOP?

Predicate in general meaning is a statement about something that is either true or false. In programming, predicates represent single argument functions that return a boolean value.

What is the theory of dispatch?

Dispatch rule is a principle of contract law that an acceptance becomes effective and binds the offeror once it has been properly mailed. However, if the offer provides that an acceptance is not effective until received then, the dispatch rule does not apply.


1 Answers

Predicate dispatch subsumes generic functions, OOP polymorphism, pattern matching, and more. A good overview is Predicate dispatching: A unified theory of dispatch by Michael Ernst, Craig Kaplan, and Craig Chambers. From its abstract:

Predicate dispatching generalizes previous method dispatch mechanisms by permitting arbitrary predicates to control method applicability and by using logical implication between predicates as the overriding relationship. The method selected to handle a message send can depend not just on the classes of the arguments, as in ordinary object-oriented dispatch, but also on the classes of subcomponents, on an argument's state, and on relationships between objects.

like image 68
dnolen Avatar answered Oct 03 '22 22:10

dnolen