Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104783 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52333 invoked from network); 18 Mar 2019 13:46:18 -0000 Received: from unknown (HELO relay.alfa-bank.ru) (217.12.97.18) by pb1.pair.com with SMTP; 18 Mar 2019 13:46:18 -0000 Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id F180F160A5; Mon, 18 Mar 2019 13:37:39 +0300 (+03) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alfabank.ru; s=mainstream; t=1552905460; bh=Yd4t3MnTWenn0uzOHVu5TqwQq2VFhd0/FWUurgVK0rg=; h=To:From:Date; b=eI8cVTsPbOr79bclN9/D5bhcfkQbyXb6utUtVEvuzBualfZ1IguEHJzOw1jJGC7YE f7G3YD8Vj23UQ7GR6CZ1kBpDFxN1Z+FDWyy4HaJRshzbtvDCnOouOJozrzLiEGn4fL ny3xCTl/7IVPCg52AHbHU0UYAJ6Pik94tsKEBL5M= Received: from relay.alfa-bank.ru (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF590160B6 for ; Mon, 18 Mar 2019 13:37:29 +0300 (+03) Received: from SMTP1.alfaintra.net (unknown [172.28.1.129]) by relay.alfa-bank.ru (Postfix) with ESMTP for ; Mon, 18 Mar 2019 13:37:29 +0300 (+03) In-Reply-To: References: To: kalle@php.net Cc: "PHP internals" , "Nikita Popov" MIME-Version: 1.0 X-KeepSent: CC2FEC6C:B7188F2B-432583C1:0036B62B; type=4; name=$KeepSent Message-ID: Date: Mon, 18 Mar 2019 13:37:27 +0300 Content-Type: multipart/alternative; boundary="=_alternative 003A5C79432583C1_=" X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1960-8.1.0.1054-24496.006 X-TMASE-Version: IMSVA-9.1.0.1960-8.1.1054-24496.006 X-TMASE-Result: 10--10.678200-10.000000 X-TMASE-MatchedRID: jbJGJtFclGZge0MF8N4SyEhEDfw/93BumX+W7bzPOQFqv/+QKNcPLmEm cboi38u3UtqD3QyCDjmcJCzlszm60WLL4j1Iu6bQ8eSmTJSmEv0k227IvqakheQydRUvl3QT4PS yLdjnTmursO3FpFFic4pAfLrfp0s5MJN0pBC3oqdDU5wIS9P5tzFcf92WG8u/buBZJ8qsrIToFQ UTpOoHp7au8HAsOABqWJKewK3e/SA5Oobd2ZO7AEg5Iem1vm3HttKJDdalq/WUvX/ci5Tjsi7GK t5dCWVKu1ajl+VCdT3xQbMtUhH69/PkRsdO/vI/QpxiLlDD9FVLf+046JY1tQA3LD7sQeFSUpN5 b4Xd/F3HCwBZhPPrgJisV2aqhjoJy7C8aiHVN2PjMjmnzyyGbX0tCKdnhB58r10pknZXGJp9j2G wzTE3vR5vYIBVaAnAyk7vAZr8zqvYzVCjhSxkJ2rkrimMItjbQtQ8d6CEPTbXBsHmCFxcTJcs5V VeukJn7HV+rwGLznB56RsqLABO3E+dzPA0Ys/z X-TMASE-SNAP-Result: 1.821001.0001-0-2-1:0,12:0,22:0,33:0,34:0-0 Subject: HA: Re: [PHP-DEV] Proposal for deprecate alternate syntax(curly braces) for array and string access From: AGromov@alfabank.ru (Andrey O Gromov) --=_alternative 003A5C79432583C1_= Content-Type: text/plain; charset="US-ASCII" > > There are some people using this syntax to distinguish between array and > > string access. It's a nice thought, but as the vast majority of code > > doesn't make this distinction (I think the only time I saw this in recent > > years was inside some old PEAR code), it's not really a useful indicator. > I personally use it because I like to quickly tell if I am doing an > operation on a string or array, it is eye candy and makes a lot of > sense. I think if anything the two syntaxes should be decoupled > instead. I think that suitable naming is more useful for this purpose. As this syntax used both for arrays and strings then "$a{2}" says absolutely nothing to anybody instead author, maybe. > The thing is, I just don't understand the rationale to remove this > feature, what the full gain from doing so is? I'm fully agree with Nikita Popov: > > > The rarity of its use also makes it rather confusing. While $foo[$x] is well established as an > > > array or string offset (or for that matter, ArrayObject) access and will be > > > recognized by any programmer coming from any number of programming languages, > > > $foo{$x} certainly is not, and is a WTF moment for people who don't happen to personally > > > use this syntax. Furthermore, curly braces is standard way to separate scope in almost all languages including PHP (except one very rare and special case). @Michael Wallner > Do I understand it right, that you're proposing deprecating accessing > $string{$offset}? I think that's an important way of differentiation > between string and array offset access. > > I'd vote "yes" for splitting syntax on array and string offset access, > but as is: -1. When we access char inside string, actually we access to element of indexed array of chars. Splitting array and string access is complex change. For now it processed on AST-creation phase and it is possible to transfer to compiler via AST-attribute. For splitting it is needs to transfer this difference into runtime. In addition, this separation can lead to much more ambiguity when migrating old code. --=_alternative 003A5C79432583C1_=--