Wednesday, March 30, 2011

Syntax Highlighting for Smalltalk

In discussions about software it is nice to show code. It can drive an abstract point home by giving an example.

I have some experience with Alex Gorbatchev's SyntaxHighlighter. It is a javascript based syntax highlighter with customizable brushes. The downside: no Smalltalk brush.

So I set out to create a Smalltalk brush for SyntaxHighlighter. The git repository SyntaxHighlighter-Smalltalk-Brush holds the result. As a test case I used the Smalltalk syntax on a postcard example. You can see an example below.

exampleWithNumber: x
   "A method that illustrates every part of Smalltalk method syntax
   except primitives. It has unary, binary, and keyword messages,
   declares arguments and temporaries, accesses a global variable
   (but not and instance variable), uses literals (array, character,
   symbol, string, integer, float), uses the pseudo variables
   true false, nil, self, and super, and has sequence, assignment,
   return and cascade. It has both zero argument and one argument blocks."

   |y|

   true & false not & (nil isNil) ifFalse: [self halt].
   y := self size + super size.
   #($a #a "a" 1 1.0)
    do: [:each | Transcript show: (each class name);
          show: ' '].
   ^ x < y
 

Monday, March 28, 2011

@smalltalkgalore Compendium

This blog is a compendium to @smalltalkgalore, a twitter stream devoted to smalltalk.

Sometimes 140 characters is not enough to express a certain view or explain a certain point. Whenever that happens you can find a blog post on the subject here.