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 08:09] – Add switch expression to failed reason ilijatovilorfc:match_expression [2020/04/25 10:03] – Adjust adt syntax ilijatovilo
Line 261: Line 261:
 </code> </code>
  
-This introduces an ambiguity with the ''+'' and ''-'' prefix operators.+This introduces an ambiguity with the ''+'' and ''-'' unary operators.
  
 <code php> <code php>
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 544: Line 552:
 ==== If you voted no, why? ==== ==== If you voted no, why? ====
  
-  1. Not interested +  Not interested 
-  2. I don't want blocks +  I don't want blocks 
-  3. Missing return values in blocks +  Missing return values in blocks 
-  4. Missing pattern matching +  Missing pattern matching 
-  5. Missing explicit fallthrough +  Missing explicit fallthrough 
-  6. BC break is not acceptable +  BC break is not acceptable 
-  7. Wanted [[https://wiki.php.net/rfc/switch_expression|switch expressions]] instead +  Wanted [[https://wiki.php.net/rfc/switch_expression|switch expressions]] instead 
-  8. 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="true">
rfc/match_expression.txt · Last modified: 2020/05/09 15:59 by ilijatovilo