Control

Smalltalk has no control structures except message passing. However, familiar control structures are defined as methods on booleans and integers. See slide sm-control.

Keyword methods

   \$ (i <= 7) \$
          \$ifTrue \! : [ m:= "oke" ]\$
          \$ifFalse \! : [ ... ]\$
  

Control structures


slide: Smalltalk -- control

For example, an if-statement may be obtained by defining the method {\it ifTrue: ifFalse:} on booleans. (Despite the use of keywords, parameter passing in Smalltalk is positional. 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.