What's the convention for referring to selectors in messages?
Last updated at 4:26 pm UTC on 14 January 2006
Question: What's the convention for referring a selector?Object>>selector or Object>>#selector
Answer: From: Bert 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.]
Now, in 1999 some guy [BF?] decided it would be neat if this was valid Smalltalk and added #>> to 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.