Smalltalk has no control structures
except message passing.
However, familiar control structures
are defined as methods on
booleans and integers.
(i <= 7)
ifTrue: [ m:= "oke" ]
ifFalse: [ ... ]
- conditional -- ifTrue: ifFalse:
- iteration -- whileTrue:
- looping -- to: by: do: [ :i | ... ]
slide: Smalltalk -- control
For example, an if-statement
may be obtained by defining
the method ifTrue: ifFalse:
(Despite the use of keywords, parameter passing in Smalltalk is
Each sequence of keywords may be
regarded as a different method.)
In a similar vein,
we may define iteration and looping.
For looping, we may employ
the parameter mechanism of blocks,
as indicated above.