Anonymous user
Category:Smalltalk: Difference between revisions
→Message Sending
Line 247:
Message sends are dynamically resolved, by letting the receiver of the message determine the method (aka code to run). The message consist of a selector (= name of the message) and optional arguments. The message syntax as:
<lang smalltalk>receiver selector</lang>
a unary message, without arguments.
<lang smalltalk>receiver part1: arg1 part2: arg2 ... partN: argN</lang>
a keyword message; the selector consists of the concatenation of the keyword parts: 'part1:part2:...partN:'.
<lang smalltalk>receiver op arg</lang>
a so called ''binary message''. The selector 'op' consists of one or more special characters, such as '+', -', '@' etc.
These are actually syntactic sugar, especially to make arithmetic look more familiar (i.e. instead of "rcvr add: foo" we can write "rcvr + foo"). These would look the same in a C-like language, although almost any non-letter-or-digit character is allowed as operator in Smalltalk.
The precedence rules are unary > binary > keyword, thus
|