Understanding the Implementation of ifTrue:ifFalse:
Damien Cassou, Stéphane Ducasse and Luc Fabresse
http://stephane.ducasse.free.fr
Yes ifTrue:ifFalse: is a message!
- Conceptually
ifTrue:ifFalse:
is a message sent to an object: a boolean!
- Heavily optimised by the compiler
Exercise
- Propose an implementation of
ifTrue:ifFalse:
- You only have objects, messages and closures
Implementing ifTrue:ifFalse:
- Remember:
[ ]
freezes body execution
value
kicks execution of a frozen code
- How to implement
ifTrue:ifFalse:
?
- Remember Not and Or?
Implementation of ifTrue:ifFalse:
Let the receiver decide!
Implementation of ifTrue:ifFalse:
Conclusion
- Sending a message selects the right method
- Let the receiver decide
[ ]
freezes computation and value
forces execution
/