Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91099 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13320 invoked from network); 6 Feb 2016 15:16:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Feb 2016 15:16:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; 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:35252] helo=mail-yk0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/F1-28222-25E06B65 for ; Sat, 06 Feb 2016 10:16:34 -0500 Received: by mail-yk0-f174.google.com with SMTP id r207so72053464ykd.2 for ; Sat, 06 Feb 2016 07:16:34 -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=QsxnszxAYbSH4aWlNBf3T/lW1uitYEPWo3RCiz6fPGY=; b=VAK/QFdW4i6ENXlECXUJyuWhaHcZKzYBVmuVoJlOYdKRPJ6hdl2KcoXd8TBeJDDbQj JV0COubNygl6zfO/gmjesSO4daW6WN8cfydBnfxAyUu5XfJSNH0cqk0LmIrERGycOoNQ mbU5BmnW1xzD1zb6z0koPMU9Heufk9qrT4MJHAv/S2J37rqsgSTbx4FBSBHMQj0cXtIF fyR/jjk6xK5aCw0L0DI0dryu6Wwf5ZB96JYu+B0LmulKDkn8Ts+R9SWittCjD4Kek4ZR FoLWyNsGgKCKkpyFw5LJ5ufNj749kQBGU+IvWU89CW8ibtTkJjWoxHiplCFyRcY9c3Yn 2wfw== 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=QsxnszxAYbSH4aWlNBf3T/lW1uitYEPWo3RCiz6fPGY=; b=dik4wWxRMZzBwffWVxx1OrGfTvRD4nsTP0bvEGCpXGjnHz3HnF80agkno0I43tvr/o nuoaO0QqwZluI3dHa7lZ0m5esJOCY/2coRdKwJ6XsFqXWHRvMvxwhwwwIW5AYrr6o5Ow V9Iimxn0GUdJmBENzsBTz88DT9N/INxhJ0CjLOnyDRsTSc7WVCjAI5HN4ggYjoOJcljI TIlslPm425P3xpctaofC2OGtijndnAEzqTsiKc7DXAnM8XxjQw4EpyRgedghMy0qoOMK U31qG/y8uwQk8MrtP13Y3irzBkSwJn4/PeNuGX4lShP2N3gxq6P9x1YgyfTkaDzyfrIp fcvQ== X-Gm-Message-State: AG10YOT0npsVw/hM8y2Fe2Jv1w4dZc56Fgo/Ddhq8O/mkKdm0qkncDoSwL8DQ75gcrZQe7KrWph3GrcJqpr5jg== MIME-Version: 1.0 X-Received: by 10.37.0.6 with SMTP id 6mr10209091yba.61.1454771791290; Sat, 06 Feb 2016 07:16:31 -0800 (PST) Received: by 10.129.148.70 with HTTP; Sat, 6 Feb 2016 07:16:31 -0800 (PST) In-Reply-To: <56AFC8CC.6040201@gmail.com> References: <56A3A01F.1020500@php.net> <56AE8735.4070901@gmail.com> <56AFC8CC.6040201@gmail.com> Date: Sat, 6 Feb 2016 16:16:31 +0100 Message-ID: To: Stanislav Malyshev Cc: Internals Content-Type: multipart/alternative; boundary=001a113d07ccd969bb052b1b73b7 Subject: Re: [PHP-DEV] [RFC] Generalize support of negative string offsets From: nikita.ppv@gmail.com (Nikita Popov) --001a113d07ccd969bb052b1b73b7 Content-Type: text/plain; charset=UTF-8 On Mon, Feb 1, 2016 at 10:06 PM, Stanislav Malyshev wrote: > Hi! > > > 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. > > The problem is that while it is generally understood, it's generally > understood wrongly. $str[$offset] is not the same operation as > $array[$offset]. There are many subtle differences. So while at the > first sight it's similar, it leads to "understanding" that is only going > to harm one in the future, when it turns out you really had wrong idea. > I think it's much better to instill the right idea from the start, even > if it means one has to take a brief look in the manual. String offset is > *not* the same as array access. > What are these subtle differences? > > 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. > > I think deprecating it was a mistake and give how much semantic load [] > carries - array access, array constructor, now there's proposal to make > it used in deconstructing too - adding string offset to it looks like > bad idea. Different things should use different syntax, as much as > possible. > I agree that different things should use different syntax. However, the point here is that all of array access, ArrayAccess and string offset access are really the same thing and as such should also use the same syntax. Array construction and destructuring on the other hand are different concerns from array access and as such do use a different syntax (even though it might reuse a token, I do not see a potential for confusion). Arguing that string offset access requires a different syntax than array access to me is the same as arguing that reading an array offset and reading an offset of an ArrayAccess object also require different syntax. Sure there are subtle differences between how plain array access works and how ArrayAccess works (especially once you get around to nested ArrayAccess), but at its core it's the same operation: Getting an element from a vector or map like structure using an offset or key. String offset access falls into the same category. There is value in emphasizing the difference of two operations by using different syntax, but there is also much value in using one, and only one, syntax to cover a set of very tightly related operations, rather than branching off in a dozen ways in an attempt to accurately capture all possible idiosyncrasies. In any case, while this is no doubt an interesting question, and one we should resolve, it is tangential to this RFC and this RFC should make no recommendations either way. I would prefer not to be forced to vote against this RFC due to the inclusion of the unnecessary and unrelated "In the documentation" section. A different proposal should concern itself with this matter. Thanks, Nikita --001a113d07ccd969bb052b1b73b7--