What's the convention for referring to selectors in messages?
Last updated at 8:35 am UTC on 15 January 2016
Question: What's the convention for referring a selector?
Object>>selector
or
Object>>#selector
Answer:
From: Vanessa Freudenberg Sent: Fri Dec 5, 2003 10:45 am
Actually, the convention is to use "Object>>selector"
without the hash mark. This can be verified by selecting ">>" and pressing Ctrl-E.
[You will see lots of messages formatted this way.]
In 1999 some guy [BF?] decided it would be neat if this was valid Smalltalk and added #>>
to class Behavior as a shortcut for #compiledMethodAt:
.
Of course, this requires you to use a Symbol as parameter, hence the #. So you can actually do a print-it on "Morph>>#delete"
in a workspace and the CompiledMethod for that method is returned.
[That's because] #delete
can be passed (a symbol), and delete
cannot.
So Yes, "Morph>>#delete"
is a valid Smalltalk expression and "Morph>>delete"
is not.