Folks,
"Perform" in Smalltalk is the primitive that allows one to
send a message whose selector is computed at runtime.
One of the most common uses of perform is as the action of a
button or menu item. A button has fields that hold a target,
selector and arguments. When the button is pressed, standard code
runs (target perform: selector with: arguments). If you cruise
around the Smalltalk classes, you will find an astounding number of
re-implementations of this idiom. I counted 26 classes that hold
some form of target and selector in their instance variables, and
this does not count their subclasses.
A wonderful feature of Smalltalk is "senders". It is
extremely easy to ask to see all the code in the system that sends a
particular message. I could not live without this feature. The
problem is, it does not detect the sends that use "perform". And,
when deleting a method, it would be nice if the system warned you
that there were still performs waiting to use that method (as it does
with conventional calls). A search that catches all uses of a
selector is also useful for renaming a selector. Besides finding the
source code that creates a menu, you can also correct all
instantiated buttons and menu items. (Become of the selector will do
this also.)
In Coke, let's make "senders" know about the perform calls.
Here are two variants of how this could be done:
1. The perform primitive only operates on an S-expressions. The
programmer would store the (target selector args) triplet in an
S-expression. S-expression would be the default way to store the
data of a button or menu item at all times. Searching all of them
would reveal the "static" performs. (It is still possible to gin up
a selector on the fly and send it... no search can catch that
beforehand.)
2. Make some other kind of special object whose purpose is to store
the data for a perform. Strongly encourage all perform data to be
stored in this kind of object.
--Ted.
--
Ted Kaehler http://www.squeakland.org/~ted/
(home) 3261 Montecito Drive, Las Vegas, NV 89120. voice (702) 456-7930
Science is about wanting to make progress *more* than wanting to be
the one who makes the progress. That is why scientists share their
results.
-- Alan Kay
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc