On Tue, 23 Mar 1999, Allen Wirfs-Brock wrote:
Brian Wilkerson once developed an interesting proposal for extending the message pattern with optional keywords and a variable numbers of repeated keywords. You can find his proposal at http://www.smalltalksystems.com/publications/varargs.pdf
A year or so ago I thought about what adding optional keyword messages to Smalltalk would be like and how it would work... Brian's proposal is pretty much in line with what I was thinking. I never thought of repeated keyword messages, though. Neat! (No more arbritary limit of 4 "with:"s when creating a new OrderedCollection. Use 17 "with:"s like you've always dreamed of! :-))
The only thing that I would add is that it would be good to have some sort of notation in the method list pane of the browser to indicate optional keywords... my original thought was to use parentheses, such as:
reMatch:(opt:)(from:)(to:)
.... to use agree@carltonfields' example. This makes it clear when browsing through code that the last three keywords were optional. (Only the method list pane would need this notation, I think... the method definition text would follow a format such as the one mentioned in the proposal.)
On Tue, 23 Mar 1999, Markus Kohler wrote:
IMHO the main problem is that it can get complicated. What if in your example the message reMatch: opt: already exists. Since you cannot know for sure who is the receiver of the message you will not know if code has to be generated for this send or not.
This wouldn't be a problem... at least based on the proposal above, the compiler would generate all possible messages (8 in this case):
reMatch: reMatch:opt: reMatch:from: reMatch:to: reMatch:opt:from: reMatch:opt:to: reMatch:from:to: reMatch:opt:from:to:
So all of these would be valid. If the message reMatch:opt: already existed for this object, the compiler would detect that and prevent you from accepting the method.
Of course, the general argument against adding optional keywords is that probably a relatively small percentage of Smalltalk methods would really need to take advantage of having several optional keywords, so it might not be worth its weight. Still, it's an interesting idea that would be cool to prototype.
- Doug Way EAI/Transom Technogies, Ann Arbor, MI dway@eai.com, dway@mat.net http://www.transom.com
Smalltalk: Guaranteed Y2T Compliant
squeak-dev@lists.squeakfoundation.org