Presource

Presource is a syntactic abstraction mechanism that allows modifications to the Smalltalk language to be done in an organized, piece-by-piece way, on a class-by-class basis.

These modifications are based on a system called message macros, inspired by Lisp macros. These allow complex Smalltalk expressions to be written as simplified message sends, without incurring a penalty for conversion to the more complex form when Smalltalk executes the expression.

For example, by registering a message macro on the selector #valueWith:as:, one can transform this code in the compiler:

aBlock valueWith: fooBar as: '42'

→ [| genSym121 |
   genSym121 := fooBar.
   [fooBar := '42'.
    aBlock value] ensure: [fooBar := genSym121]] value

as well as create other such previously-impossible semantics for Smalltalk code.

Complete documentation is provided in the commentary section in Presource.st, found in the .star downloadable package. Useful examples are provided in the base message macro library in PresourceLib.st.

Download the latest .star package at http://nocandysw.com/starchive/NoCandyPresource.star

Note: Presource supports the new GST syntax only in 2.95e and later versions.

Resources

User login