Re: Draft RFC: foreach iteration of keys without values
| From: | Josh Bruce | Date: | Wed, 02 Sep 2020 20:52:10 +0000 |
| Subject: | Re: Draft RFC: foreach iteration of keys without values | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111796@lists.php.net to get a copy of this message | ||
> On Sep 2, 2020, at 12:05 PM, Michael Voříšek - ČVUT FEL <vorismi3@fel.cvut.cz> wrote:
>
> I like "void", as "null" can be ambiguous.
>
> Imagine function example($a = 'default value 1', $b = 'default value 2') {}
>
> With "void", we can allow skipping arguments in advance to the default pamameter
> value like example(void, 'test');.
>
I second the use of “void" over “null” - for what it's worth.
Mainly the rationale for me is that I would like to reserve “null” for empty or non-existent
object.
[
“key” => 1,
“key2” => null // empty object
]
“void" is already being used on the tail of functions to say, “This thing does not return
anything; and can be ignored.”
So:
foreach($collection as $key => void)
Says, “This thing can be ignored” (void) and not, “this thing doesn’t exist but maybe
should” (null).
Cheers,
Johs