Friday, March 28, 2003

Generalizing Polymorphism With Multimethods

David Mertz:

Object-oriented programming gains much of its versatility through polymorphism: objects of different kinds can behave in similar ways, given the right contexts. But most OOP programming is single dispatch; that is, just one designated object determines which code path is taken. Conceptually, a more general technique is to allow all the arguments to a function/method to determine its specialization. This article presents an implementation of multiple dispatch in Python, and shows examples where this makes for better programs.

1 Comment RSS · Twitter


Instead of mucking around with experimental Python extensions, consider that the first OO language that achieved an ANSI standard has multiple dispatch. That's right, Common Lisp!

Leave a Comment