Re: [RFC] skipping optional parameters
| From: | Daniel Macedo | Date: | Wed, 18 Apr 2012 10:38:45 +0000 |
| Subject: | Re: [RFC] skipping optional parameters | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60179@lists.php.net to get a copy of this message | ||
You can't do that, NULL is a perfectly acceptable value to pass into a
function, you wouldn't be able to know when you wanted to pass NULL or
use the default value, e.g.:
function fn1($a = false, $b = nul, $c = 1)
{
var_dump($a, $b. $c);
}
// your idea
fn1(NULL, NULL, 10), // NULL, NULL, 10
// vs. using a reserved word
fn1(default, default, 10), // FALSE, NULL, 10
Cheers,
On Wed, Apr 18, 2012 at 11:21, Peter Cowburn <petercowburn@gmail.com> wrote:
> On 18 April 2012 10:25, Daniel Macedo <admacedo@gmail.com> wrote:
>>
>> But I couldn't support the comma train, for the insane «lots of
>> parameters» case, would hate to read some fn($some,,,, $var,,, $other)
>> call.
>> I'd rather reuse a reserved word like 'default' (or even get a shorter
>> one?)
>>
>
> How about "null"? (Tongue firmly in cheek)