Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91048 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66716 invoked from network); 1 Feb 2016 17:34:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2016 17:34:35 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.174 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.160.174 mail-yk0-f174.google.com Received: from [209.85.160.174] ([209.85.160.174:33398] helo=mail-yk0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/49-07168-B279FA65 for ; Mon, 01 Feb 2016 12:34:35 -0500 Received: by mail-yk0-f174.google.com with SMTP id z13so56840105ykd.0 for ; Mon, 01 Feb 2016 09:34:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Jkergy6VjmX144gUg8CJOCG20gPZdTMEA0s3mKQ001g=; b=Nz1kQWozRX1T0uKnY0GZEvKvso6pEaoIuFZ3VbDpWvovG9VBsUaEgMu7PYlAMlreJJ hmgFrTax0DNE5grxzEMikwLG+gjn/AkeCIOsYbUbRYN+OnRt9c/g76FDHlZUhuqGDcf8 gT056yT8YBvwsrfh0Kcwak1g6B4UPFD1ZQl0xz/8oI+S0bxKv+pI7RGSPV83TCk2oBbg R3vLyG71c4DM48hQuX0Fk7PgGH/y+FBDwuSkD+c8cSL2bmGsy0VKSqVOrO0gCAI1Dg3J R8utiLbnVVEwOcUX/dl0kLJNdQj135AzgcJQ0d7YamiEpSZvzGXtBh1eE3pmfrbfAlqe c1WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Jkergy6VjmX144gUg8CJOCG20gPZdTMEA0s3mKQ001g=; b=WlU4h8hJlCXlE5a8kejs+rNjW+RX1i6ZNwFlPNklAZY7i+Q6kQ6LodbVLwbZvKerJr Mh6gNVkx1yqS4DZGhA3Ei2GjUnw3q0jwUOgriOa0TplPNiF08hEk2B8uQqaxZLlzAtai K6MrSXp4As9jykBV0I+xDCxdoyYbG/dJrFMi0LULAFSwLNs1v0Lzv/+IYbIIE7/FxKzO 2+dR44zRf+Z9NwRVpJBmzVySbDa1OlWO64072w/XTzDDYoPl1eBdOcJI1AO5BGxTXacL VwFeTnGt+zmuhaRUjj7kqRtrrAavTfTq2a1bdJIM9CnH9zc/Oar9WWOgj4rJ3UwB2edy hNrg== X-Gm-Message-State: AG10YOQK2VsSnFfXE2oZmrCEMThocQzmB+L/JYnwZdZ3C4psrpqsGWnLsmGdKR62ewAI51al5+x2QfwSwACRFA== MIME-Version: 1.0 X-Received: by 10.37.3.137 with SMTP id 131mr12064099ybd.46.1454348072583; Mon, 01 Feb 2016 09:34:32 -0800 (PST) Received: by 10.129.148.70 with HTTP; Mon, 1 Feb 2016 09:34:32 -0800 (PST) In-Reply-To: <56AE8735.4070901@gmail.com> References: <56A3A01F.1020500@php.net> <56AE8735.4070901@gmail.com> Date: Mon, 1 Feb 2016 18:34:32 +0100 Message-ID: To: Stanislav Malyshev Cc: Internals Content-Type: multipart/alternative; boundary=001a11c045ce3f0d30052ab8cc17 Subject: Re: [PHP-DEV] [RFC] Generalize support of negative string offsets From: nikita.ppv@gmail.com (Nikita Popov) --001a11c045ce3f0d30052ab8cc17 Content-Type: text/plain; charset=UTF-8 On Sun, Jan 31, 2016 at 11:14 PM, Stanislav Malyshev wrote: > Hi! > > > The only concern I have is that support of negative indexing will break > > symmetry with (proper) arrays, where we cannot support negative indexing. > > I think that was the main source of objections to this proposal in the > past. However, as one might say, string offsets are already not > symmetrical to array offsets - e.g. you can do $array["foo"] but not > $string["foo"]. > > > However this is unlikely to be a significant issue. (I do however play > with > > the thought of reutilizing the obsolete {} indexing syntax to act as > offset > > indexing instead.) > > I think it may be a good idea to start recommending using {} for string > offsets and [] for arrays. While both syntaxes may work for strings, the > intent (and expected handling of negatives, in this case) is much > clearer when different syntax is used. I strongly disagree with this. $str[$offset] is well-recognized, generally understood syntax that does not require familiarity with language peculiarities. $str{$offset} might be clear to a Perl programmer, but to anyone else this is just guesswork, with a typo being a reasonable assumption. We should be deprecating this alternative syntax instead of recommending its use. I was under the impression that we *were* already discouraging its use and it has already been temporarily deprecated. Nikita --001a11c045ce3f0d30052ab8cc17--