default args (was Re: Any reason for assigning block parameter in inject:into:)

Philippe Marschall philippe.marschall at gmail.com
Sun Apr 29 15:14:24 UTC 2007


2007/4/29, J J <azreal1977 at hotmail.com>:
> >From: nicolas cellier <ncellier at ifrance.com>
> >Reply-To: The general-purpose Squeak developers
> >list<squeak-dev at lists.squeakfoundation.org>
> >To: squeak-dev at lists.squeakfoundation.org
> >Subject: Re: Any reason for assigning block parameter in inject:into:
> >Date: Sun, 29 Apr 2007 15:00:02 +0200
> >
> >However, this pattern should be limited to very few optional args, because
> >N optional args make (2 raisedTo: N) different messages.
> >That's a lot of code to maintain.
> >
> >Nicolas
>
> You're over-stating this.  It's simple.  You provide the base method that
> takes all options and one method for each different interface to that method
> you provide.  And this approach certainly scales better then setting the
> defaults by hand, although Python style defaulting would be less typing.
>
> Languages like Smalltalk can use keyword arguments for default arguments
> [1], languages like Python use special default argument syntax [2] and
> languages that were not designed as well (at least in this area) have to
> rely on 'var = var || default' nonsense.
>
> [1] IMO, this is the superior method for a dynamic language because the
> others require runtime checks to be done every time the function is entered,
> while this way it is only a compile time check.
>
> [2] This is certainly better then having to manually type out every default
> case, but (afaik) it is still a runtime check for a dynamic language.

Nicolas is right, this gets real messy, real fast. See Seaside:
Canvas <-> HtmlBuilder

Cheers
Philippe

> _________________________________________________________________
> The average US Credit Score is 675. The cost to see yours: $0 by Experian.
> http://www.freecreditreport.com/pm/default.aspx?sc=660600&bcd=EMAILFOOTERAVERAGE
>
>
>



More information about the Squeak-dev mailing list