55 ms·
> Polymorphic dispatch (is that the term?) to replace if blocks. It looks like you're talking about Predicate Dispatch. http://c2.com/cgi-bin/wiki?PredicateDis
by Dn_Ab 12y ago
> Polymorphic dispatch (is that the term?) to replace if blocks.
It looks like you're talking about Predicate Dispatch. http://c2.com/cgi-bin/wiki?PredicateDispatching http://c2.com/cgi-bin/wiki?PredicateDispatching
- slowmovintarget 12y agoPolymorphic dispatch is the specific reason for polymorphism in Object-Oriented Programming. It is more generically known as "dynamic dispatch": http://en.wikipedia.org/wiki/Dynamic_dispatch http://en.wikipedia.org/wiki/Dynamic_dispatch You'll encounter the term in Bertrand Meyer's Object-Oriented Software Construction for example: http://www.goodreads.com/book/show/946106.Object_Oriented_Software_Construction http://www.goodreads.com/book/show/946106.Object_Oriented_So...
- Dn_Ab 12y agoDynamic dispatch is a special case of predicate dispatch. In particular, captainmuon pointed out that: >Pattern matching in functional languages solves this in a different way. captainmuon wanted a more flexible way of dispatching on types similar to what can be done with Pattern matching (which is also a special case of predicate dispatch). In the post I linked to above this example is given: Basically, instead of basing the dispatch on an "is_a" check, you check whether a general predicate is valid on the argument. So, in imaginary syntax instead of writing int foo( int a, int b): if a > 0 return a else return b-a you'd write: int foo ( gt_zero? a, int b): return a int foo ( int a, int b): return b