On 02-09-2020 21:31, Dik Takken wrote:
> Even if we decide that it is not worth the trouble for foreach loops,
> there are other cases where this new syntax can work well. Array
> destructuring has already been mentioned.
Replying to myself: It just occurred to me that array destructuring
already allows omitting values:
[, , $username] = getUserData();
I still do find using void here more clear though, more intentional.
> Another case is the one where a function intentionally does not use one
> of the arguments passed to it. This happens easily when using callbacks
> or when implementing interfaces. A function declaration could look like
> this:
>
> function foo($arg, void) {}
>
Given the array destructuring syntax, an alternative syntax might be:
function foo($arg,)
Again, I would prefer to see void here in stead of a trailing comma. In
function calls a trailing comma is already allowed and it has a
completely different meaning, which can be confusing.
Regards,
Dik Takken
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php