Re: [RFC][Under Discussion] Add functions array_key_first()and array_key_last()
| From: | Rowan Collins | Date: | Wed, 20 Jun 2018 17:02:49 +0000 |
| Subject: | Re: [RFC][Under Discussion] Add functions array_key_first()and array_key_last() | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102332@lists.php.net to get a copy of this message | ||
On 20 June 2018 at 17:19, Levi Morrison <levim@php.net> wrote:
> Bad behavior of existing functions does not mean we should create new
> functions with the same bad behavior. If you believe lack of education
> regarding array destructuring is an issue then we can use this example
> specifically in the docs for these functions; problem solved.
>
I'm torn between your point of view and Enno's.
Note that we're not talking about "lack of education regarding array
destructuring", because there's no array being destructured; we're talking
about "lack of education regarding the side-effect behaviour of the array
destructuring operator when given a non-array input". It's a pretty
obscure, seemingly undocumented, language feature, and one which the RFC
you linked seems to have originally classed as unwanted behaviour.
If it was used in a prominent example, maybe other uses for this idiom
might start cropping up, and people would start using it. Even so, if I saw
it while reviewing or debugging code, I would probably be tempted to
refactor it to something "less clever" so that the intent was clearer.
On balance, I don't think the example you gave is a compelling reason, on
its own, to go with your suggested signature. The separate functions feel
more convenient in a lot of cases, but maybe less so in others.
Regards,
--
Rowan Collins
[IMSoP]