Re: Re: Named arguments revisited
| From: | Michael Walter | Date: | Thu, 12 Jan 2006 08:58:13 +0000 |
| Subject: | Re: Re: Named arguments revisited | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-21484@lists.php.net to get a copy of this message | ||
On 1/12/06, Robert Cummings <robert@interjinn.com> wrote:
> On Thu, 2006-01-12 at 01:25, Jason Garber wrote:
> > Hello Aidan,
> >
> > I think named parameters would be a useful feature... I'll leave it
> > at that.
> >
> > Here is a coding idea for you, in case you hadn't considered it...
> >
> > function highlight($text=NULL, $needle=NULL, $strip_links=NULL, ...)
> > {
> > is_null($text) && $text = SOME DEFAULT VALUE;
> > is_null($needle) && $text = SOME DEFAULT VALUE;
> > is_null($strip_links) && $text = SOME DEFAULT VALUE;
> > ...
> > }
>
> Ummmmm, how is that different (ignoring the copy paste bugs in the &&
> $text parts) than:
>
> function highlight
> (
> $text=SOME DEFAULT VALUE,
> $needle=SOME DEFAULT VALUE,
> $strip_links=SOME DEFAULT VALUE,
> ...
> )
> {
> ...
> }
>
To quote Jason, "In [the] way, [that] the user doesn't have to
remember the default values,
just the offsets.".
Michael