Dispatch

Summary: An experimental multiple dispatch facility for Smalltalk
Author: Avi Bryant
Owner: Avi Bryant (avi)
Co-maintainers: <None>
Categories:
Homepage:
PackageInfo name: Dispatch
RSS feed:

Description:

This provides simple CLOS-like multiple dispatch for Smalltalk methods. It operates on a selector naming convention. For example, you might have a generic selector #add:to:, with more specific versions #addNumber:to:, addString:to:, add:toArray:, addDictionary:toDictionary:, and so on. With this package loaded, you would implement the generic #add:to: method like this:

add: x to: y
^ self dispatch

The most specific of the add:to: methods, based on the classes of self, x and y, would be invoked. From within one of the specific implementations, you can also send "self nextMethod", which will invoke the next-most-specific version - this is like a super send but more general.

Currently, this experimental implementation is absurdly slow (maybe 10 sends/s). In the future it will likely be sped up by 2 or 3 orders of magnitude.

Releases


Back