TOM
 
The New Selector Syntax
 
 
TOM Home
TOM Tasks

FAQ
News
Highlights
Publications
Documentation
Download TOM
TOM Software
Bug Database
Mailing Lists

Mail:
tiggr at gerbil.org

Short Cuts:
Tesla
TOM/Gtk
GP
MU

Snapshots:
all of 'em
tom [an error occurred while processing this directive]
tesla [an error occurred while processing this directive]
mu [an error occurred while processing this directive]
tomgtk [an error occurred while processing this directive]

Released:
all of 'em
tom 1.1.1
tomgtk 0.11
tesla 0.91
gp 0.5
mu 1.0

Misc:
GIF free NOW!

On a sunny Monday afternoon, Michael Brouwer sent this opinion to the TOM mailing list: In response I changed the syntax of getting a selector into what he suggested. If you never need to write anything in C, you can safely forget about the old syntax. However, for glueing TOM and C, you'll probably need to know how selectors are handled internally.

Examples

Suppose you have this object a, which implements the following (silly) method:

int (result)
	 tell Foo object
   toMultiply int p
	   by int q;
An invocation of this method is straightforward:

[a tell b toMultiply 6 by 9];
The same invocation, but going through perform could look like this:

[a perform selector (int tell Foo toMultiply int by int)
   with (b, 6, 9)];
Thus, the selector lists the return type, followed by the method's name parts and argument types. Put differently: the stuff between the parenthesis is like a method heading, but without any argument names. To clarify: compare the original method declaration above with the selector written like this:

selector (int
		  tell Foo
	    toMultiply int
		    by int)
Do not be fooled by the Foo type in the selector; it is the same selector as:

selector (int tell All toMultiply int by int)
or

selector (int tell MutableArray toMultiply int by int)
because for selectors, there is no difference between objects, just like the TOM semantics for method overloading do not discern between different object classes (all objects are objects). On the other hand, denoting the object type in the selector is great for documentational purposes.

Small print

In TOM, the syntax type (expression) is used for type casts. Example: long a = 0x1234567890; int b = int (a); Because of the new selector syntax, the selector type can no longer be used in type casts. Not that it really matters, since the only thing that can be cast to a selector is a selector, which is not a very useful operation. It is, however, an irregularity, albeit one of which the advantages outweigh the disadvantages.
Up: Highlights
 
Copyright © 1997-2002 Programmers Without Deadlines