next up previous contents
Next: 4.4 Organization of Source Up: 4 Style Guide Previous: 4.2 Naming Methods   Contents

Subsections

4.3 Instance-specific Dispatch

Often there are situations whether the user will want to specialize a method in some argument position for a specific object. There are various reasons to do this, and various factors to consider when deciding to do so.

4.3.1 Motivations

Two common patterns where the developer wants to specialize to a single object emerge from using Slate. First, there are domain objects which naturally have special non-sharable behavior. For example, True is clearly a particular object that helps define the semantics of the whole system, by representing mechanical truth abstractly. In other situations, the same pattern occurs where one has a universal concept, or locally an absolute concept within a domain.

Second, there are situations whether the user is demonstratively modifying the behavior of some thing in order to acheive some prototype that behaves in some situation as they desire. Depending on whether the user decides to share this behavior or not, the instance-specific behavior may or may not migrate to some shared Traits object. In either case, this is an encouraged use of objects and methods within Slate.

4.3.2 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 most literals of that nature, with the exception of Symbols.


next up previous contents
Next: 4.4 Organization of Source Up: 4 Style Guide Previous: 4.2 Naming Methods   Contents
The Slate Project 2003-07-29