Appendices
Syntax cheat sheet — the whole syntax on a postcard, pseudo-variables & reserved identifiers, common message reference, keyboard shortcuts in Pharo, dialect & version history, learning resources and suggested study plan (12 weeks).
Appendices
45.1 Syntax cheat sheet — the whole syntax on a postcard Ralph Johnson's famous "Smalltalk syntax on a postcard" method shows almost every syntactic element in one method:
Everything else is just messages:
45.2 Pseudo-variables & reserved identifiers Current receiver; lookup starts above the defining class The sole UndefinedObject true, false Sole instances of True and False Current execution context (stack frame)
These six cannot be assigned. There are no keywords otherwise: ifTrue:, whileTrue:, class, new, return are ordinary messages (^ is syntax for return). Important globals (not reserved, but don't shadow them): Smalltalk, Transcript, Processor, World, Undeclared.
45.3 Common message reference class, isKindOf:, isMemberOf:, respondsTo: =, ==, ~=, ~~, hash Equality and identity
printString, displayString, printOn:, storeString copy, shallowCopy, deepCopy, postCopy
isNil, notNil, ifNil:, ifNotNil:, ifNil:ifNotNil: inspect, browse, halt, error:
perform:, perform:with:, instVarNamed:, -> Reflection, associations
new, new:, with:with:, withAll:, new:withAll: add:, addAll:, remove:, remove:ifAbsent:, removeAll: Adding / removing
at:, at:put:, at:ifAbsent:, at:ifAbsentPut:, first, last
do:, collect:, select:, reject:, detect:ifNone:, inject:into:
anySatisfy:, allSatisfy:, count:, includes:, occurrencesOf:
size, isEmpty, notEmpty, ifEmpty:ifNotEmpty: sorted, sorted:, reversed, asSortedCollection:, max, sum Ordering / aggregates
asArray, asOrderedCollection, asSet, asBag, asDictionary
keys, values, keysAndValuesDo:, associations, removeKey:
,, copyWith:, copyFrom:to:, allButFirst, first: Strings & symbols
,, size, asUppercase, asLowercase, capitalized, reversed
includesSubstring:, beginsWith:, endsWith:, indexOf:
substrings, substrings:, lines, trimBoth Splitting / trimming
copyReplaceAll:with:, format:, join: asNumber, asInteger, asSymbol, asString, asByteArray
matchesRegex:, allRegexMatches:, match: String streamContents: [:s |...], readStream
+ - * /, //, \\, quo:, rem:, **, raisedTo: abs, negated, squared, sqrt, ln, log:, exp, sin, cos
floor, ceiling, rounded, truncated, roundTo: even, odd, isPrime, isZero, sign, between:and:
max:, min:, gcd:, lcm:, factorial, atRandom asFloat, asInteger, asString, printString:, printPaddedWith:to:
to:do:, to:by:do:, timesRepeat:, to: Loops / intervals @, seconds, days, milliSeconds Points and durations 45.4 Keyboard shortcuts in Pharo
Use Cmd on macOS instead of Ctrl.
Do it and go (inspect inline) Accept (compile/save the method or class definition) Browse the selected class Implementors of the selected message Senders of the selected message Spotter (search everything) Open a Playground Open a System Browser Ctrl+Z / Ctrl+Shift+Z Ctrl+Space or Tab Format code (in Calypso code pane) Alt+. (Cmd+. on macOS)
Interrupt a running process (opens a debugger) Right-click / Ctrl+click Context menus with refactorings 45.5 Dialect & version history Dialect / release Smalltalk-72 (Xerox PARC) Smalltalk-80 / Blue Book published Digitalk Smalltalk/V (PCs) GemStone (Servio Logic) object database
ParcPlace Systems → Objectworks, later VisualWorks (1991; Cincom since 1999)
IBM VisualAge Smalltalk (→ VA Smalltalk, Instantiations, 2005) Squeak (Apple → open source)
Dolphin Smalltalk (Object Arts; open source 2016) GNU Smalltalk (3.2.5 in 2013) Cuis Smalltalk (Juan Vuletich) Pharo forked / Pharo 1.0 Pharo 5 — Spur VM / Pharo 6 — 64-bit
Pharo 7 — Git/Iceberg, Calypso browser; Glamorous Toolkit Pharo 9 — Spec2, headless VM Squeak 6.0 and Pharo 10 / Pharo 11
Pharo 12 — fluid class syntax by default 45.6 Learning resources
Free books (books.pharo.org and squeak.org):
*Pharo by Example* (Pharo 9 edition) — Stéphane Ducasse, Gordana Rakić, Sebastijan Kaplar, Quentin Ducasse
*Learning Object-Oriented Programming, Design and TDD with Pharo* — Stéphane Ducasse
*Deep into Pharo*, *Enterprise Pharo: a Web Perspective*, *Pharo with Style*, *Concurrent Programming in Pharo*, *The Spec UI Framework*, *Unified FFI*
*Squeak by Example* — Black, Ducasse, Nierstrasz, Pollet *Smalltalk-80: The Language and its Implementation* ("Blue Book") — Goldberg & Robson (freely available online)
*Computer Programming using GNU Smalltalk* — Canol Gökel *Dynamic Web Development with Seaside* — Ducasse, Renggli, Shaffer, Zaccone (book.seaside.st) Other books:
*Smalltalk Best Practice Patterns* — Kent Beck (essential) *Smalltalk, Objects, and Design* — Chamond Liu
*The Design Patterns Smalltalk Companion* — Alpert, Brown, Woolf
*Test-Driven Development: By Example* — Kent Beck Courses: the free Pharo MOOC (*Live Object Programming in Pharo*, mooc.pharo.org) and *Advanced Object-Oriented Design and Development with Pharo*.
Sites & community: pharo.org, squeak.org, cuis-smalltalk.org, gtoolkit.com, the Pharo Discord, pharo-users and squeak-dev mailing lists, ESUG (European Smalltalk User Group) conference, UK Smalltalk User Group, r/smalltalk, Exercism's Pharo track, *Pharo Weekly* news.
45.7 Suggested study plan (12 weeks) History, image model, install Pharo, master the tools
Objects, literals, messages, precedence, variables, cascades
Blocks, control structures, booleans — Part I exercises Classes, methods, variables, inheritance
Polymorphism, lookup, metaclasses, numbers — Project 1 Collections, iteration, strings, streams, files
Exceptions, SUnit, TDD in the debugger, refactoring — Part II exercises
Git/Iceberg/Tonel, Metacello, reflection, traits — Project 2
Patterns, announcements, concurrency, Morphic & Spec2 — Project 3
Roassal, Zinc/Teapot/Seaside/JSON, persistence — Project 4 FFI, VM & profiling, headless & GNU Smalltalk, deployment — Part III exercises
Complete projects, best practices — one of Projects 5–8 🎓 Final Words
You've traveled from 3 + 4 to metaclasses, closures, reflection, live debugging, web servers, object databases, and native calls — all in a language whose syntax fits on a postcard. Smalltalk's real lesson is a way of working: everything is an object you can talk to, the system is always alive, and you shape it from the inside. Keep your code in Git, write tests, code in the debugger, read the system's own source, and join the friendly Pharo and Smalltalk communities. The ideas you learned here power much of modern software — now you know where they came from. Happy Smalltalking! 🎈
exampleWithNumber: x
"Shows messages of all three kinds, an argument, a temporary, a global,
literals, pseudo-variables, assignment, a cascade, a block, and a return."
| 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"comment" 'string' #symbol $c (character)
16r1F 2r101 1.5e3 3/4 1.25s2 #(1 $a 'b' #c) #[1 2 3] { 1+1. 2 }
| temp | var := expr ^ expr (return) stmt1. stmt2
receiver unary receiver + arg receiver key: a word: b
receiver msg1; msg2 (cascade) [ :arg | | t | stmts ] (block)
self super nil true false thisContext (pseudo-variables)
Precedence: ( ) > unary > binary (left to right) > keyword