In Python, the "basic" constructs such as if/else
, short-circuiting boolean operators, and loops are part of the language itself. In Smalltalk, they are all just messages. In that sense, while both Python and Smalltalk agree that "everything is an object", Smalltalk goes further in that it also asserts that "everything is a message".
[EDIT] Some examples.
Conditional statement in Smalltalk:
((x > y) and: [x > z])
ifTrue: [ ... ]
ifFalse: [ ... ]
Note how and:
is just a message on Boolean
(itself produced as a result of passing message >
to x
), and the second argument of and:
is not a plain expression, but a block, enabling lazy (i.e. short-circuiting) evaluation. This produces another Boolean
object, which also supports the message ifTrue:ifFalse:
, taking two more blocks (i.e. lambdas) as arguments, and running one or the other depending on the value of the Boolean.