Re: [RFC] Named parameters

From: Date: Sun, 29 Mar 2015 14:56:33 +0000
Subject: Re: [RFC] Named parameters
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 29 March 2015 at 12:28, Gints Murans <[email protected]> wrote:

> What happened to this RFC? This is a really great idea for php.

The 'Skip Params' RFC (https://wiki.php.net/rfc/skipparams) went to
vote and was declined.
The 'named params' RFC (https://wiki.php.net/rfc/named_params) author
has been working on stuff they feel is more important.

> Reading over some old code, this way it would be a lot easier to understand what that second
> parameter boolean = true is:

You can do this right now, if you want to:

getIdByTitle('sample', $insert = true);

> About syntax: $insert => true seems kind of confusing:
>        $insert = true;
>       getIdByTitle('sample', $insert => $insert)

You shouldn't need it for the case where you're actually already using
a parameter e.g. getIdByTitle('sample', $insert); already indicates
what the parameter is. The only place where you could argue this
syntax is needed is when you're passing in just a bare 'true' which
has no syntactic meaning associated with it.

That syntax works for all versions of PHP, so I guess a new syntax
that achieves the same thing is unlikely to be that popular an idea.

cheers
Dan


Thread (46 messages)

« previous php.internals (#85529) next »