Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-21 Thread Yasuo Ohgaki
Hi Nikita, On Thu, Jan 22, 2015 at 12:42 AM, Nikita Popov wrote: > On Wed, Jan 21, 2015 at 2:57 PM, Dmitry Stogov 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

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-21 Thread Nikita Popov
On Wed, Jan 21, 2015 at 2:57 PM, Dmitry Stogov 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. >

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-21 Thread Rowan Collins
Yasuo Ohgaki wrote on 21/01/2015 02:48: I don't think that's an either/or situation: in most cases, it would be up to the user to create that independent iterator, because there's no general algorithm for cloning one that the engine could use. (Think of an iterator proxying a dat

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-21 Thread Benjamin Coutu
ough this is not really necessary unless the array is actually changed during iteration Cheers, Ben == Original == From: Dmitry Stogov To: Yasuo Ohgaki , Nikita Popov Date: Wed, 21 Jan 2015 14:57:59 +0100 Subject: Re: [PHP-DEV] Fixing strange foreach behavior. Hi, Yeah,

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-21 Thread Dmitry Stogov
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

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-20 Thread Yasuo Ohgaki
Hi Rowan, On Mon, Jan 19, 2015 at 12:05 AM, Rowan Collins wrote: > On 18 January 2015 at 01:01, Yasuo Ohgaki wrote: > >> Hi Rowan, >> >> On Sat, Jan 17, 2015 at 8:43 PM, Rowan Collins >> wrote: >> >>> My concern is, at what cost? Given how rarely used the internal pointer >>> is, >>> are we ca

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-18 Thread Rowan Collins
On 18 January 2015 at 01:01, Yasuo Ohgaki wrote: > Hi Rowan, > > On Sat, Jan 17, 2015 at 8:43 PM, Rowan Collins > wrote: > >> My concern is, at what cost? Given how rarely used the internal pointer >> is, >> are we carrying around a chunk of extra memory with every array just on >> the >> off-ch

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-17 Thread Yasuo Ohgaki
Hi Rowan, On Sat, Jan 17, 2015 at 8:43 PM, Rowan Collins wrote: > My concern is, at what cost? Given how rarely used the internal pointer is, > are we carrying around a chunk of extra memory with every array just on the > off-chance that it will be used, or is there some magic that makes it > ze

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-17 Thread Rowan Collins
On 16 January 2015 at 21:15, Yasuo Ohgaki wrote: > Hi Rowan, > > On Sat, Jan 17, 2015 at 1:22 AM, Rowan Collins > wrote: > >> Yasuo Ohgaki wrote on 16/01/2015 08:40: >> >>> Hi all, >>> >>> Take a look at >>> >>> http://3v4l.org/HbVnd >>> >>> foreach should not affect internal(zval) array positio

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-16 Thread Yasuo Ohgaki
Hi Rowan, On Sat, Jan 17, 2015 at 1:22 AM, Rowan Collins wrote: > Yasuo Ohgaki wrote on 16/01/2015 08:40: > >> Hi all, >> >> Take a look at >> >> http://3v4l.org/HbVnd >> >> foreach should not affect internal(zval) array position, but it does. >> I'm not sure why foreach works this way, but HHVM

Re: [PHP-DEV] Fixing strange foreach behavior.

2015-01-16 Thread Rowan Collins
Yasuo Ohgaki wrote on 16/01/2015 08:40: Hi all, Take a look at http://3v4l.org/HbVnd foreach should not affect internal(zval) array position, but it does. I'm not sure why foreach works this way, but HHVM behavior is reasonable. IMHO. PHP 7 would be perfect opportunity fix this behavior. Any

[PHP-DEV] Fixing strange foreach behavior.

2015-01-16 Thread Yasuo Ohgaki
Hi all, Take a look at http://3v4l.org/HbVnd foreach should not affect internal(zval) array position, but it does. I'm not sure why foreach works this way, but HHVM behavior is reasonable. IMHO. PHP 7 would be perfect opportunity fix this behavior. Any comments? Regards, -- Yasuo Ohgaki yohg.