On Fri, Jan 30, 2015 at 11:23:19AM +0400, Dmitry Stogov wrote:
> Hi,
> 
> I'd like to start discussion about fixing inconsistent "foreach" statement
> behavior.
> The implementation is almost done. It not only fixes inconsistencies in a
> defined by RFC way but also improves performance in most usual cases,
> because now foreach by value over array doesn't require array duplication.
> 
> https://wiki.php.net/rfc/php7_foreach
> 
> https://github.com/php/php-src/pull/1034
> 
> I'm going to continue work on implementation improvement and may be fixing
> related behavior of some internal functions when they used on array
> iterated by foreach by reference (e.g. array_unshift()). However, the
> conceptual behavior defined in RFC is not going to be changed anymore.

I think that I am raising a concern that is not real, but I'll do so anyway.

You write:

    This will lead to copy-on-write on attempt of array modification inside the
    loop.  As result, we will always iterate over elements of array originally
    passed to foreach, ignoring any possible array changes.

I think that you mean modification of the array and that this does not relate to
modification of array elements. Ie will code like the following still work:

foreach($_POST as &$v)
    $v = trim($v);

Otherwise - good.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to