Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:98403
Return-Path: <rowan.collins@gmail.com>
Mailing-List: contact internals-help@lists.php.net; run by ezmlm
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 13567 invoked from network); 4 Mar 2017 16:09:48 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
  by localhost with SMTP; 4 Mar 2017 16:09:48 -0000
Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass
Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass
Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.41 as permitted sender)
X-PHP-List-Original-Sender: rowan.collins@gmail.com
X-Host-Fingerprint: 74.125.82.41 mail-wm0-f41.google.com  
Received: from [74.125.82.41] ([74.125.82.41:38134] helo=mail-wm0-f41.google.com)
	by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
	id 8F/F1-10274-6C6EAB85 for <internals@lists.php.net>; Sat, 04 Mar 2017 11:09:43 -0500
Received: by mail-wm0-f41.google.com with SMTP id t193so35467126wmt.1
        for <internals@lists.php.net>; Sat, 04 Mar 2017 08:09:42 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=subject:to:references:cc:from:message-id:date:user-agent
         :mime-version:in-reply-to;
        bh=p6zt63y8iAGtQpOZnIi7E/5tnI2DH+0LGQkMPmAPMtM=;
        b=PeS9YuxEd5Oi6Israrl7tymhz0NKPQ8y74k7FxWAoJT2rx82+GzfqRfbu/eBlzbL1X
         C/tIz+8dZ5Naw8GuMDkfOyFE802527ICK/htqZYoj3FqzBm90+XKzkzvVQmMqdXSeBdm
         mAt+drFEkDJdnPYfVO39hRAaNFH8d8mp0EdnXzm88ZnJmMNaYSkBugSI6Ac9AYmOoc4P
         OA6i3MG6tgIYOiJmSbzBbmvtvnY2oVAYxdBPzfc/5z+DV/DBDf67H3lfykAHKQaEQZf4
         yZlCXDEVVDZ3aecvV8k1Y+ZEP4K57YoyaOfs+DN2o6y1QP00qEcjzEYXa7hv4m2BUxSI
         rJDA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:cc:from:message-id:date
         :user-agent:mime-version:in-reply-to;
        bh=p6zt63y8iAGtQpOZnIi7E/5tnI2DH+0LGQkMPmAPMtM=;
        b=PHGsl8vFLOc/mImk5ncrQwKPuuFTq3tsZmfAkOmFmtF082xK68+9fOoNA1EXfF4lDP
         8tpclPvOk9Nc87wpPt6W4qpWyQvbLk3ETqXhftNVK6sgqoOcYCpY9OPHbslOj0WRjqWn
         RtFIN3b3gEpJHpuFfaShgJp4t6BCD99E62ss1wzBOmwnKVcBOhNluJZpytIvXKaaCU1U
         Cwd1r4YYoeM3jBdSznSNVTSZYI/CqeVAUdcbpz9BxJ69Vr1upy3WWcW+7pLM/FW7X+U4
         HUek7Jq2nf2mI8D/Rd8wqHfCwZaDKZMZucp5vk0BLHnG6F82cFZLgKVJx4qAOuXEqsep
         EULQ==
X-Gm-Message-State: AMke39m+LNuc3yQ/MhpAn9GS2InM3DeJVDi0bAJtvU0aYM1eRnWwee/O1WKi6BpWqSmlPA==
X-Received: by 10.28.107.141 with SMTP id a13mr7376611wmi.61.1488643779766;
        Sat, 04 Mar 2017 08:09:39 -0800 (PST)
Received: from ?IPv6:2a00:23c4:4bd2:6e00:709e:fd12:12ca:ba98? ([2a00:23c4:4bd2:6e00:709e:fd12:12ca:ba98])
        by smtp.googlemail.com with ESMTPSA id e72sm5153733wma.5.2017.03.04.08.09.38
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sat, 04 Mar 2017 08:09:38 -0800 (PST)
To: =?UTF-8?Q?Pedro_Magalh=c3=a3es?= <mail@pmmaga.net>
References: <CAJd4=YYAuN295mu91rVFBGbiw-ZNFegv5bhWHCwX9=fXh_MyOA@mail.gmail.com>
 <CAJd4=YZQ2vd2f_q+RqVLTLhDKGV+gaQsYG+Ncf79JZQ7RWuwcg@mail.gmail.com>
 <3d5cfa50-5f5d-5633-99ad-052a6b5ac599@gmail.com>
 <CAJd4=YbBRS3SbF3XLBVMPQzBY0Z5tFQNwmnHg9U6t14sA9A7cA@mail.gmail.com>
Cc: PHP internals <internals@lists.php.net>
Message-ID: <466f3491-321f-2aca-ea5a-4128b07356df@gmail.com>
Date: Sat, 4 Mar 2017 16:09:35 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101
 Thunderbird/45.7.1
MIME-Version: 1.0
In-Reply-To: <CAJd4=YbBRS3SbF3XLBVMPQzBY0Z5tFQNwmnHg9U6t14sA9A7cA@mail.gmail.com>
Content-Type: multipart/alternative;
 boundary="------------E925367DB51CAD7AAF2D5339"
Subject: Re: [PHP-DEV] Re: On arrays starting with a negative index
From: rowan.collins@gmail.com (Rowan Collins)

--------------E925367DB51CAD7AAF2D5339
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi Pedro,

On 02/03/2017 23:10, Pedro Magalhães wrote:
>
>     Would other behaviour also be affected?
>
>     For instance:
>
>     $foo = [ -2 => true ];
>     $foo[] = true;
>     $foo[] = true;
>     var_dump($foo);
>
>     If so, this is a much wider BC break; if not, why not?
>
>
> It would indeed. Internally, nNextFreeElement is initialized with 0 
> and updates on larger values. In the PR 
> (https://github.com/php/php-src/pull/2383/files#diff-fd78a0a3f78ea28c6907f907f25b908eR798) I'm 
> allowing it to be set to a negative value if it is the first element.

I haven't built with the patch to check, but have you checked it behaves 
correctly with other combinations? For instance [-10 => true, -5 => 
true, true] or ['string_key' => true, -10 => true, true]


> I completely agree on the impact of this change. But I also believe 
> that this behaviour would be preferable.

I broadly agree that the proposed behaviour would be preferable in 
itself. Unfortunately, in a language with 20 years of history, and 
millions of lines of deployed code, we don't have the luxury of looking 
at behaviour in isolation, we have to think about the consequences of 
change as well as the end result.

Would you be willing to draft an RFC for this change? If you're not 
familiar with the process, have a look at this: 
https://blogs.oracle.com/opal/entry/the_mysterious_php_rfc_process

You'll need to make the case for the change, and try to consider all the 
angles. For instance:

- Exactly what behaviour will change, and how? We already have three 
different things that are affected, and there may well be others.
- What code might rely on the current behaviour? What kind of bugs might 
such code exhibit if it's not updated after the change? How can users 
write code that will work the same before and after the change?
- On the other side, what are the benefits of the change? What is the 
harm caused by the current behaviour, e.g. potential for bugs or mistakes?

This may seem like a lot of work for such a simple patch, but the more 
we discuss it, the clearer it becomes that this would be a significant 
language change, so we need to make sure it's considered properly.

Regards,

-- 
Rowan Collins
[IMSoP]


--------------E925367DB51CAD7AAF2D5339--