advice needed about default arguments for a method

Brian Rice water at tunes.org
Tue Dec 14 16:54:13 UTC 2004


Slate uses a language extension called optional keywords for this, 
where any message-send may pass along a number of &-prefixed keywords 
(read & as "with") and then ordinary expressions to override any 
defaults for auxiliary inputs. Each method can then define auxiliary 
inputs which it responds to and which can have default expressions to 
initialize them. The auxiliary keywords can be passed in any order or 
combination. One tiny annoyance is that adding keywords to any 
message-send raises its arity to keyword-level instead of just binary 
or unary.

It's an idea; don't know if you'll like it. We have gradually 
incorporated them more and more into the libraries and it has a 
pleasant effect on the protocols.

On Dec 10, 2004, at 2:07 AM, Stéphane Rollandin wrote:

> Ned Konz wrote:
>
>> But the problem is that the default arguments are dependent on the 
>> context in which the method is called.
>
> they would not be in my case (actually plain Number arguments would do 
> it, I do not need the Compiler evaluate: stuff).
>
> really what I want are default arguments defined within the method 
> source itself. it may seem odd but that's exactly my need :)
>
> ... of course if this really an illegal design pattern in Smalltalk 
> (which I'm afraid it is), then I'll have to change my needs :)
--
Brian T. Rice
LOGOS Research and Development
http://tunes.org/~water/




More information about the Squeak-dev mailing list