SmalltalkSyntax In A Postcard
Short summary of SmalltalkSyntax and demonstration extreme simplicity.
This is copied from someone else, from whom I lost references. (If you know who is the original author, please edit. Also, this seems to be public domain. If you find it's not, also please edit.)
exampleWithNumber: x "A method that illustrates every part of Smalltalk method syntax except primitives. It has unary, binary, and keyboard messages, declares arguments and temporaries, accesses a global variable (but not an 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
This covers almost all syntax in SmalltalkLanguage.
Although it states it accesses a "global variable (but not an instance variable)", it also accesses a method temporary, which shares the syntax with instance variables. Just remove the "| y |" bit and the later mention to y is an instance variable.
Some things not covered (besides primitives) are:
myBraceArray := {y. y + x. 'a string', ' concatenation'}. "myBraceArray has 3 elements: 1-the object referenced by y at the time of creation. 2-the result of sending '+ x' to y at the time of creation. 3-the result of sending "", ' concatenation' "" to "" 'a string' ('a string concatenation', if you didn't mess with String class)."
[ :w :x | "<- this are block parameters" | y z | "<- and this block temporaries" "..." ]
x := y. "a binding" y _ x. "also a binding"Note: Dialects that understand '_' will usually print it as a left pointing arrow (mimicking original Smalltalk code).
Also, AllStatementsAboutSmalltalkAreFalse. ;) Oh, yeah, and SyntaxFollowsSemantics.
fs.