typestar

The three message shapes in Smalltalk

Unary, then binary, then keyword: the whole grammar.

"Three message shapes: unary, binary, keyword -- in that order."
| galley |
galley := 'headline'.

"Unary messages bind tightest."
Transcript show: galley asUppercase; cr.
Transcript show: galley size printString; cr.

"Binary messages come next: + , = and friends."
Transcript show: (3 + 4 * 2) printString, ' -- left to right'; cr.

"Keyword messages carry arguments in their name."
Transcript show: (galley copyFrom: 1 to: 4); cr.
Transcript show: ('lead' , 'ing'); cr.

How it works

  1. Unary messages like asUppercase and size bind tightest.
  2. Binary operators run strictly left to right: 3 + 4 * 2 is 14.
  3. Keyword messages interleave name and arguments: copyFrom:to:.

Keywords and builtins used here

The run, in numbers

Lines
14
Characters to type
472
Tokens
63
Three-star pace
60 tpm

At the three-star pace of 60 tokens a minute, this run takes about 63 seconds.

Type this snippet

Step 3 of 3 in Values, step 3 of 31 in Language basics.

← Previous Next →