Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104746 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32411 invoked from network); 15 Mar 2019 18:15:25 -0000 Received: from unknown (HELO mail-io1-f67.google.com) (209.85.166.67) by pb1.pair.com with SMTP; 15 Mar 2019 18:15:25 -0000 Received: by mail-io1-f67.google.com with SMTP id v4so7474293ioj.5 for ; Fri, 15 Mar 2019 08:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6Ti28dSYqyBLDyojS6TnTWS8l7oSkZ1Jgh4m2e85mqA=; b=M8N7csk490nGwYd5rBNT97ZFjovK51+sc576g1GKMri6YSMK3yEn5WA2BWX/NiMrtU 53Axh6mcWTtZpvb3odA5mXVolLY7SAMlN47zAqEBADIWya3JIhCp8X5z7fSsZGcJBtUl Ki0g/HuiDFdeSYnYNrppw2yYY7y2undLKtZyEjIcSDwHOJg4+vpiRjdiqG2ycLYkvDAB qy3+7n3KwEKNNoPrRONunZ3piHNbTYbx7YwIjf9yWshgqH4d7viNRqvOkWfI4ld7LVQF poCJWBu5nSNvjVGsF294gQEop86rAu1Rdh1vnevcuvQzFRwSmH6+Ej6JBEIC5FiOE3sr XnPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6Ti28dSYqyBLDyojS6TnTWS8l7oSkZ1Jgh4m2e85mqA=; b=l3Nfqmy2Xuk99WqWcFgapgD/1tM5p/O3q6uG4emJqR6EM0YiVXaGNhrfWqXCcmgy7Q x411g0nawg7aQ5mMPgr+hjUQA39PhOwxNOMOko34XbSiaPmlpLX0Flyvp6tHKGpCqzuc hWQRuijLIHhoP8FuPTsJuRpa9MEQf8/8mX+uLJ5w5yN0Lyootblrsa6goz6lhIFCY6oO 6UANAgXvpDkCcoLKMrH8R81Qd6DUan1qRAL+F/Zd4ikSbPqoniAibomrsGJCo4B/sv/Y +Dw5JxxyDNcNriHnPDYYCAUWa7lYc9QaSx/nP1FfP2FvaxGJiJ38SCTSFJkG5fm9zvdC LMzA== X-Gm-Message-State: APjAAAURey9bc6hAmx1B3I8Q7k8taGK8VbT/WGE8WUDnNIstufq30ZOt i151Nq9y82URAsZQ0Ya/YbMYRlKdDm94cIvHIWVi3Q== X-Google-Smtp-Source: APXvYqxxcDJ6TQlN94ebWBTbMTKkB7QLRKEJ7yY/QA2xXQIx0DI/TbMiKznfCUqNCKmwt3a56UJqrhjVbkROFQrDXas= X-Received: by 2002:a5d:88d3:: with SMTP id i19mr2607807iol.187.1552662364918; Fri, 15 Mar 2019 08:06:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 15 Mar 2019 16:05:48 +0100 Message-ID: To: Andrey O Gromov Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000b799dd05842360bc" Subject: Re: [PHP-DEV] Proposal for deprecate alternate syntax(curly braces) for array and string access From: nikita.ppv@gmail.com (Nikita Popov) --000000000000b799dd05842360bc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 15, 2019 at 2:39 PM Andrey O Gromov wrote= : > Reasons to deprecate curly braces syntax:: > 1. Two ways to do the same thing. > 2. It is very rarely used nowadays. > 3. It is almost not documented. There is only two short =E2=80=9CNOT= E=E2=80=9D about > it. > 4. Also, this syntax has reduced functionality. You can't use it for > pushing element into array =E2=80=9C$arr{} =3D 1;=E2=80=9D, creating arra= y =E2=80=9C$a=3D{1,2};=E2=80=9D or in > other similar cases. > 5. Deprecation and following removal will free this syntax for other > features. For example: array/string slice, absolute offset access, > =E2=80=9Cwindows=E2=80=9D (like =E2=80=9Cslice=E2=80=9D in GoLang), etc. > > Proposal > https://wiki.php.net/rfc/deprecate_curly_braces_array_access > > Patch diff > > https://github.com/php/php-src/compare/PHP-7.4...rjhdby:deprecate_alterna= te_array_access > > Migration script > > https://github.com/rjhdby/php-src/blob/deprecate_alternate_array_access/c= onvert_array_access_braces.php I'm okay with this. This syntax has already been deprecated once, though it was reverted for reasons I don't remember. 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. 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. I'd prefer to phase out this syntax entirely and not reuse it for any other purpose. Reusing syntax is generally a not so good idea, because it means that the same syntax has different meaning in different PHP version. Nikita --000000000000b799dd05842360bc--