Technical Track: Smalltalkiana (Traits for Smalltalk and OOPAL)


The papers cover the application of traits to the Smalltalk collection classes and the array programming features of FScript.

Traits for the collection classes:

The speaker started with an overview of the collection classes in Smalltalk and the differences between them. For instance we have ordered and unordered collections, identity and equality comparisons, etc.

There is a problem though, that single inheritance prevents a natural catagorization because ordered and unordered collections can both be of fixed or variable size, etc. Each dimension adds to the single inheritance heirarchy flowering. To overcome this, the implementors pushed subclass behaviour into superclasses who are not responsible for them.

Then the implementors tend to disable messages (such as #at: on Set).

The branching vs. improperly assigning responsibilty is the problem tackled by the authors. (via mixins?)

traits aim to add remove the duplication of code while avoiding the complexity of multiple inheritance or mixins.

traits are pure behaviour. They are like partially abstract interfaces. adding centre and radius attributes to an object would allow it to behave Circle behaviour. the behaviour would come along with the trait.

implementors of traits must provide the attributes required by the traits. It's very important that the attributes supporting a trait are unambiguous. The author went through a few techniques that remove ambiguity.

Back to applying traits to the collection hierarchy.

there was a demonstration using squeak, for which there is some tool support.

why traits (vs. mixins or MI):

mainly because of the flattening property of traits.

taking questions: the questions focus mostly on the utility (why bother), and more formal engineering processes (the application of traits to formal type sytems).

OOPAL:

array programming supports the sending of a message to an entire array of polymophically equal object at the same time (without having to use for loops or the like).

the cononical example is given an array of obejcts of flights (with airplanes, pilots,etc) select aspects of the flights.

in APL, X and Y are arrays: 'X + Y', Java involves creating iterators and looping over them.

OOPAL extends the APL ideas into message based OOP languages (FScript).

{1, 2, 3} * 2 = {2, 4, 6}
{1, 2, 3} * {10, 20, 30} = {10, 40, 90}

The presenter goes into some examples that express the power of the array programming system, including alternate ways to achieve #select: (where the elements of Array respond to #name).

Array at: Array name > 'Smith'

vs.

Array select: [:each | each name > 'Smith']

Posted: Tue - October 28, 2003 at 04:40 PM      


©