rfc:deprecate_dollar_brace_string_interpolation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
rfc:deprecate_dollar_brace_string_interpolation [2021/03/13 18:22] – Overhaul language to make it more compelling. crellrfc:deprecate_dollar_brace_string_interpolation [2022/03/11 16:19] – Update 2022 ilutov
Line 4: Line 4:
   * Author: Ilija Tovilo, tovilo.ilija@gmail.com   * Author: Ilija Tovilo, tovilo.ilija@gmail.com
   * Status: Draft   * Status: Draft
-  * Target Version: PHP 8.1+  * Target Version: PHP 8.2
   * Implementation: TBD   * Implementation: TBD
  
Line 14: Line 14:
   2. Braces outside the variable ("{$foo}")   2. Braces outside the variable ("{$foo}")
   3. Braces after the dollar sign ("${foo}")   3. Braces after the dollar sign ("${foo}")
-  4. Dynamic variable lookup ("${expr}")+  4. Dynamic variable lookup ("${expr}", equivalent to ''(string) ${expr}'')
  
-All of these have their pros and cons, but in practice options 3 and 4 are easily confused (both by users and the parser) due to the similar syntax, are strictly less capable than the first two options, and are rarely used in practice.  Option 3 is specifically less capable than 2, and option 4 is built on variable-variables with all the complexity and weirdness that brings with it.+Options 1 and 2 have their pros and cons, but 3 and 4 are easily confused due to overlapping syntax, are strictly less capable than the first two options, and are rarely used in practice.  Option 3 is specifically less capable than 2, and option 4 has different semantics (dynamic variable lookup) that is rarely useful in string interpolation.
  
-This RFC proposes to deprecate options 3 and 4 in PHP 8.and remove them in PHP 9.0.  That leaves only two string interpolation options: direct (simple variable only) and powerful (the one that does the most now).+This RFC proposes to deprecate options 3 and 4 in PHP 8.and remove them in PHP 9.0.  That leaves only two string interpolation options: direct (simple variable only) and powerful (the one that does the most now).
  
 ===== Status quo ===== ===== Status quo =====
  
-The first issue is that all four options support different subsets of syntax.  That is needlessly confusing, both for the user and for the parser.+All four options support different subsets of syntax.  That is needlessly confusing, both for the user and for the parser.
  
 ==== Simple variable interpolation ==== ==== Simple variable interpolation ====
Line 125: Line 125:
 ==== Comparison to other languages ==== ==== Comparison to other languages ====
  
-A number of other languages use ''%%${foo}%%'' style string interpolation, most notably bash and Javascript (in template literals).  However, its behavior is different from that in PHP.  In PHP, that syntax means variable-variables.  In Javascript, it supports arbitrary expressions (making it technically a superset of PHP's existing option 2).  In its current form, options 3 and 4 are of limited use, and confusing for users from other nearby languages as they behaves quite differently.+A number of other languages use ''%%${foo}%%'' style string interpolation, most notably bash and Javascript (in template literals).  However, its behavior is different from that in PHP.  In PHP, that syntax means variable-variables.  In Javascript, it supports arbitrary expressions 2).  In its current form, options 3 and 4 are of limited use, and confusing for users from other nearby languages as they behaves quite differently.
  
 ===== Conclusion ===== ===== Conclusion =====
Line 151: Line 151:
 ===== Vote ===== ===== Vote =====
  
-Voting starts 2021-xx-x and ends 2021-xx-xx. +Voting starts 2022-xx-x and ends 2022-xx-xx. 
  
 As this is a language change, a 2/3 majority is required. As this is a language change, a 2/3 majority is required.
  
-<doodle title="Deprecate ${} string interpolation in PHP 8.and remove them in PHP 9.0?" auth="ilutov" voteType="single" closed="true">+<doodle title="Deprecate ${} string interpolation in PHP 8.and remove them in PHP 9.0?" auth="ilutov" voteType="single" closed="true">
    * Yes    * Yes
    * No    * No
 </doodle> </doodle>
  
rfc/deprecate_dollar_brace_string_interpolation.txt · Last modified: 2022/05/05 08:17 by ilutov