Messages: Composition and Precedence
Damien Cassou, Stéphane Ducasse and Luc Fabresse
http://stephane.ducasse.free.fr
Composition: from Left to Right!
What happens when we have two messages of the same kind?
- Execution from left to right
is equivalent to
- Ease the composition of messages
Complete Message Precedence
- (Msg) > Unary > Binary > Keywords
- From left to right
Precedence Example
- unary (squared) first
- then binary (
+
)
Precedence Example
- binary (
+
) first
- then keyword-based (
raisedTo:
)
Precedence Example
- unary messages
- then binary from left to right
Precedence Example
Parentheses take Precedence!
Should use ()
The Price for Simplicity
Only messages:
+
- is a message, no precedence
- can be redefined in domain classes
- Simple
- One limit: no mathematical precedence
No Mathematical Precedence
- should be rewritten using parentheses
No Mathematical Precedence
- should be rewritten using parentheses
Summary
- Three kinds of messages: unary, binary and keywords
- (...) > unary > binary > keywords
- Then from left to right
- There is no mathematical precedence because mathematical operations are plain messages
- Arguments are placed inside message structure:
- 2 between: 0 and: 5 (the message is
between:and:
)
/