next up previous contents
Next: Organization of Source Up: Instance-specific Dispatch Previous: Motivations   Contents

Limitations

There are factors which weigh against the use of dispatch on objects with non-shared behaviors. Generally, these just amount to a few simple reasons. First, the behavior will not be shared, which is obvious, but sometimes not clear to the author. Second, the author may mistake an object for its value or attributes, such as Strings, which are not unique per their value, and so get unexpected results if they dispatch on a String instance. The same is true for all literals of that nature, with the exception of Symbols.

The general rule for defining a method on an instance which is a lightweight ``value'' object, is that the object must be reliably re-identifiable, as Symbols are for the language, or through naming paths from the lobby or some other object that the user is given access to, such as a method argument. Otherwise, the user must be careful to hang on to the identity of the given object, which offsets any polymorphism gains and exposes implementation details unnecessarily.



Brian Rice 2004-08-24