Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117313 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72964 invoked from network); 12 Mar 2022 12:59:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Mar 2022 12:59:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 312B11804AB for ; Sat, 12 Mar 2022 06:23:37 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 12 Mar 2022 06:23:36 -0800 (PST) Received: by mail-il1-f178.google.com with SMTP id p2so7924976ile.2 for ; Sat, 12 Mar 2022 06:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=s500VdOwGuP1CKg543hwKX7ulvEAsJemUGBTvlcIuEA=; b=F9soYaOFXbwvY23CO3lh7kpy5qdbNqJqcbdyxq2vnen2EPlgyBDtAbPqtjR5mzGd0t NVbMiFyigUptpgtwVxMJ3YbTdDr2OEDFjkKcof+eT7SohmUhJQtAhwtjivsnBoeIFJPn 72rxJbLYy95GQ9V2ZHH4dEfSZO0isAcJb6Qon5KSByToJQqBXxbk7R8velPvS6DQ8yAX 94nNcnRbpMqhRMaObL5sKziyDnFX1NOR1z6jjmSWbbEhWiLFa5HKohsW/G9yPeI/k3jt 9TKoTY3FjbVto49lhMe4oAyevXgWl9AhUf9wtb17kIcTj6k8V+dvZN9Cn2g5xD1vn6x6 TUPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=s500VdOwGuP1CKg543hwKX7ulvEAsJemUGBTvlcIuEA=; b=cy4NxXNg2k80RUnQV8NwsDX1e71CNF99Tb3CRGF+DfukGQN/atoSbERm9BhEZZuiL6 xQHnSnUkkD2iNaWdffwKt5YaLzuE/OOqMSuutDLLQKjDij+ldFBe0El+c8rhQi3FWMdq Si9iFbOMM+iMy4hPfmZZrRm8lSvysmE/ZiQ7QFwPcWkYJoP0tB7f47v8jevoDb2urLP0 t/MLYWVTpnWUFZzdl/n62zj2EnKBMGF2eJ4GWmSJC80ymtvkn5b+gs6y/E+sTZKprF9k BWH5DLyFHeWq27VqGiu0wky2FMlCnJk+a1a3MbAnRt2qrLJIaiCcaLNNVL+jUKtCYQo6 +uFg== X-Gm-Message-State: AOAM531NVZyFGJGPug6G7TOZBc8Z9T8bs/fZ4y0Yk9XiNdvK0fNWuVti vj9SAUdZEb0xJJZHKwcsWOuBoXsojWcCHtpz7sjAhRwltEM= X-Google-Smtp-Source: ABdhPJwgcR0LCZzbGn7SHBTYlerQhV0gfJRQDqn5GkH7a8zgKJQ8p5L52pbu5HLi/gnWeY6fHQGAQiX7G+Z0O85Mv3E= X-Received: by 2002:a92:dacc:0:b0:2c6:b0d:240e with SMTP id o12-20020a92dacc000000b002c60b0d240emr11322184ilq.177.1647095015856; Sat, 12 Mar 2022 06:23:35 -0800 (PST) MIME-Version: 1.0 References: <20220312031138.5e0669a4@platypus> <20220312123015.3713538b@platypus> <492ECA79-EC68-4BEB-AD67-B26A1D68D399@gmail.com> In-Reply-To: <492ECA79-EC68-4BEB-AD67-B26A1D68D399@gmail.com> Date: Sat, 12 Mar 2022 15:23:25 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC][Under discussion] Deprecate ${} string interpolation From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi everyone, thanks for the feedback! I'll be responding to everyone in the same e-mail to minimize noise. --- Hi Rowan > I presume the intent here is that the engine will generate an > E_DEPRECATED each time such a string is encountered. Do you know yet if > that will be easy to implement? I think some simple string handling is > built into the parser, so there may not be a single code path to look at. I created an implementation just now to answer this question. Luckily there is a single code path and it was easy to implement. https://github.com/php/php-src/compare/master...iluuu1994:deprecate-dollar-curly-encaps-var?expand=1 > The other question which I'm sure lots of users will have when they see > the deprecation is: How easy is it to adapt usages of the deprecated > syntax to use the non-deprecated variants? I'm guessing it's not as > simple as moving the $ sign, because as you point out the syntaxes have > different semantics; is there a general rule that users and/or tools can > use to generate correct replacements? For option 3, it is as simple as moving the $ sign. It supports just two forms: * `"${foo}"` -> `"{$foo}"` * `"${foo[expr]}"` -> `"{$foo[expr]}"` As for option 4, it can also be transformed to 2 but requires additional curly braces. * `"${expr}"` -> `"{${expr}}"` I have not intended to create a migration tool so far but that's something worth considering. > A final thought is that I seem to remember a previous thread (from > Nikita?) about the "$foo[bar]" syntax, which is also confusing. Maybe we > should consider deprecating that at the same time? I agree that the inconsistent syntax is unfortunate. In this case at least it's more concise so it has some justification for being there. > @Ilija It might be worth adding the above example to the RFC , to show that "Option 2" can actually do > everything that the other options do and more. Absolutely, I will do that. --- Hi BohwaZ > The 4th one is very useful. > > $v = ${'param_' . $name}; Like Rowan mentioned, the RFC does not propose to deprecate variable variables, just variable variables as a form of string interpolation. You'll still be able to use variable variables, even in strings, like noted above, just as form 2. --- Hi Andreas > First of all it would make it much easier for me to see what impact this > RFC has if there were any numbers in it of how many large-scale > repositories on for example github are affected by this. You're absolutely right. I will attempt to gather some numbers. For option 3, I also think "not widely used" is just plain wrong. As for option 4, I'm fairly confident it only exists by accident 95% of the time. > But on the other hand, and that's much more important to me, I am > missing the part where you explain the concrete benefits of that > deprecation for the evolution of the language. Basically, I was planning on suggesting more powerful string interpolation in 2020, what the RFC refers to as future scope. But with there already being 4 different types of syntax I was afraid of adding fuel to the fire and decided to clean up the existing syntax first. It's not a technical problem, just a usability problem. > at least for me - as long as something is not in the way of a new > feature or a strategy we leave it as it is. I think this comes down to personal opinion. IMO this mindset hinders progress. Removing a feature from the language takes many years, which is why I believe it's essential to remove the baggage every once in a while. There are other languages that attempt to keep perfect backward compatibility and they are universally criticized for being complicated and confusing. There's no single one argument I can provide here as this comes down to your personal view on where the language is going in the next decade. Ilija