I don't quite understand some syntax seen in books

David N. Smith (IBM) dnsmith at watson.ibm.com
Mon May 14 17:15:21 UTC 2001


At 13:13 -0400 5/13/01, Thomas Porter wrote:
>I have looked over some smalltalk tutorials and am now looking at Kent Beck's
>"Smalltalk Best Practice Patterns".
>
>I have come across some code fragments that I do not understand, such as:
>
>Controller>>controlActivity
>	self controlInitialize.
>	self controlLoop.
>	self controlTerminate.
>
>What the heck is the '>>' between 'Controller' and 'controlActivity'?
>
>Is this simply an indication that controlActivity is a method in class
>Controller?  If so, what kind of method, class or instance?
>
>I have seen this construction in other places, but I am afraid I am new enough
>to Smalltalk that I had not run across this usage yet, particularly not in my
>current bible, Mark G's Squeak book.

Thomas:

Actually, this is a variant of a valid expression. Squeak can evaluate, for example:

	String>>#indexOf:

and will answer a compiled method. The use of the syntax in documentation is a way to refer to a specific method in a specific class. Thus:

	To find the position of $a in a string, see the method String>>#indexOf: which...

Some people leave out the #, but properly it should be present.

When used as in your example, it is an extension to the Smalltalk syntax used only for descriptive purposes;  the pound sign should not be present, I think, since what follows is not always a symbol. For example, this is probably the right way to express #indexof: in String:

	String>>indexOf: aCharacter
	   "body"

Dave

-- 
_______________________________
David N. Smith
IBM T J Watson Research Center
Hawthorne, NY
dnsmith at watson.ibm.com





More information about the Squeak-dev mailing list