Re: Fixing strange foreach behavior.
| From: | Yasuo Ohgaki | Date: | Thu, 22 Jan 2015 04:54:27 +0000 |
| Subject: | Re: Fixing strange foreach behavior. | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80950@lists.php.net to get a copy of this message | ||
Hi Nikita,
On Thu, Jan 22, 2015 at 12:42 AM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> On Wed, Jan 21, 2015 at 2:57 PM, Dmitry Stogov <dmitry@zend.com> wrote:
>
>> Hi,
>>
>> Yeah, I think changing foreach behaviour in more consistent and efficient
>> way may make sense.
>> If we won't use HashTable.nInternalPointer we won't need to copy
>> immutable arrays.
>> The same for nested foreach on the same array.
>> We could also eliminate all the HashPosition magic introduced to keep
>> PHP5 behavior.
>>
>> On the other hand some apps may relay on current weird behavior.
>>
>> I remember, long time ago Nikita made some related proposal.
>> Nikita, could you please send a link.
>>
>> Thanks. Dmitry.
>>
>
> Original proposal is the patch linked at the end of
> https://bugs.php.net/bug.php?id=53405. However that was aimed
> at making
> external HashPosition iteration to work like the internal pointer, so we
> could make it fully independent while keeping most of the current behavior.
> I fear it would make the implementation even more complicated than it
> already is.
>
> For PHP 7 we have the option to alter the iteration semantics for edge
> cases a bit (especially interaction of iteration and changes to the array).
> I'll have to try out some ideas in that direction and report back.
>
Great to hear this.
I'm looking forward outcomes!
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net