The Do-It Yourself Guide to Squeak Primitives

1. Be sure you Really Need a Primitive

Generally, there are several reasons to hand-code primitives. In the example I give below, I need to access an OS-level driver for MIDI input. There's just no way I can write this in Smalltalk. For examples of performance-optimization primitives (i.e., where the prim's body is written in Smalltalk and translated to C for performance reasons only), look at John Maloney's sound synthesis classes (AbstractSound and its subclasses) for examples of how to write low-level Smalltalk code for translation into C. (I don't really go into this here.)

Please note that if lots of us start writing random and not-really-well-motivated primitives we won't be able to share any code at all any more. The namespace of primitives is limited; there is no formal mechanism for managing that space with multiple primitive-writers; and merging two virtual machines with different primitive extensions can be a *real* pain. Do not do this lightly.