rfc:match_expression

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:match_expression [2020/04/25 09:46] – Rename prefix op to unary ilijatovilorfc:match_expression [2020/04/25 10:32] – Start voting ilijatovilo
Line 2: Line 2:
   * Date: 2020-04-12   * Date: 2020-04-12
   * Author: Ilija Tovilo, tovilo.ilija@gmail.com   * Author: Ilija Tovilo, tovilo.ilija@gmail.com
-  * Status: Under Discussion+  * Status: Voting
   * Target Version: PHP 8.0   * Target Version: PHP 8.0
   * Implementation: https://github.com/php/php-src/pull/5371   * Implementation: https://github.com/php/php-src/pull/5371
Line 323: Line 323:
 </code> </code>
  
-The keyword ''match'' could be a bit misleading here. Because I have no strong opinion on this it will be moved to a secondary vote.+The keyword ''match'' could be a bit misleading here. A potential gotcha is passing truthy values to the match which will not work as intended. But of course this issue remains regardless of dropping ''(true)'' or not. 
 + 
 +<code php> 
 +match { 
 +    preg_match(...) => {}, // preg_match returns 1 which is NOT identical (===) to true 
 +
 +</code> 
 + 
 +Because I have no strong opinion on this it will be moved to a secondary vote.
  
 ===== Miscellaneous ===== ===== Miscellaneous =====
 ==== Arbitrary expressions ==== ==== Arbitrary expressions ====
-A match condition can be any arbitrary expression. Analogous to ''switch'' each condition will be checked from top to bottom until the first one matches. If a condition matches the remaining conditions won't be evaluated+A match condition can be any arbitrary expression. Analogous to ''switch'' each condition will be checked from top to bottom until the first one matches. If a condition matches the remaining conditions won't be evaluated.
  
 <code php> <code php>
Line 429: Line 437:
  
     // Algebraic data types if we ever get them     // Algebraic data types if we ever get them
-    let Ast\BinaryExpr($lhs, '+', $rhs) => ...,+    let Ast::BinaryExpr($lhs, '+', $rhs) => ...,
 } }
  
Line 523: Line 531:
 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="Would you like to add match expressions to the language?" auth="ilijatovilo" voteType="single" closed="true">+<doodle title="Would you like to add match expressions to the language?" auth="ilijatovilo" voteType="single" closed="false">
    * Yes    * Yes
    * No    * No
Line 530: Line 538:
 Secondary vote (choice with the most votes is picked): Secondary vote (choice with the most votes is picked):
  
-<doodle title="Should the semicolon for match in statement form be optional?" auth="ilijatovilo" voteType="single" closed="true">+<doodle title="Should the semicolon for match in statement form be optional?" auth="ilijatovilo" voteType="single" closed="false">
    * Yes    * Yes
    * No    * No
Line 537: Line 545:
 Secondary vote (choice with the most votes is picked): Secondary vote (choice with the most votes is picked):
  
-<doodle title="Should we allow dropping (true) condition?" auth="ilijatovilo" voteType="single" closed="true">+<doodle title="Should we allow dropping (true) condition?" auth="ilijatovilo" voteType="single" closed="false">
    * Yes    * Yes
    * No    * No
Line 553: Line 561:
   - Other   - Other
  
-<doodle title="If you voted no, why?" auth="ilijatovilo" voteType="multi" closed="true">+<doodle title="If you voted no, why?" auth="ilijatovilo" voteType="multi" closed="false">
    * 1    * 1
    * 2    * 2
rfc/match_expression.txt · Last modified: 2020/05/09 15:59 by ilijatovilo