rfc:match_expression
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:match_expression [2020/04/24 20:19] – Remove unused sentence ilijatovilo | rfc: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: | + | * Status: |
* Target Version: PHP 8.0 | * Target Version: PHP 8.0 | ||
* Implementation: | * Implementation: | ||
Line 212: | Line 212: | ||
</ | </ | ||
- | For the time being the following code will result | + | For the time being using blocks in match expressions that use the return value in any way results |
<code php> | <code php> | ||
Line 218: | Line 218: | ||
0 => {}, | 0 => {}, | ||
}; | }; | ||
+ | //> Match that is not used as a statement can't contain blocks | ||
- | //> Match that not used as a statement can't contain blocks | + | foo(match ($x) { |
+ | 0 => {}, | ||
+ | }); | ||
+ | //> Match that is not used as a statement can't contain blocks | ||
+ | |||
+ | 1 + match ($x) { | ||
+ | 0 => {}, | ||
+ | }; | ||
+ | //> Match that is not used as a statement can't contain blocks | ||
+ | |||
+ | //etc. | ||
+ | |||
+ | // Only allowed form | ||
+ | match ($x) { | ||
+ | 0 => {}, | ||
+ | } | ||
</ | </ | ||
Line 245: | Line 261: | ||
</ | </ | ||
- | This introduces an ambiguity with the '' | + | This introduces an ambiguity with the '' |
<code php> | <code php> | ||
Line 261: | Line 277: | ||
</ | </ | ||
- | When '' | + | A '' |
<code php> | <code php> | ||
Line 307: | Line 323: | ||
</ | </ | ||
- | The keyword '' | + | The keyword '' |
+ | |||
+ | <code php> | ||
+ | match { | ||
+ | preg_match(...) => {}, // preg_match returns 1 which is NOT identical (===) to true | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 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 '' | + | A match condition can be any arbitrary expression. Analogous to '' |
<code php> | <code php> | ||
Line 413: | Line 437: | ||
// Algebraic data types if we ever get them | // Algebraic data types if we ever get them | ||
- | let Ast\BinaryExpr($lhs, | + | let Ast::BinaryExpr($lhs, |
} | } | ||
Line 507: | 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=" | + | <doodle title=" |
* Yes | * Yes | ||
* No | * No | ||
Line 514: | Line 538: | ||
Secondary vote (choice with the most votes is picked): | Secondary vote (choice with the most votes is picked): | ||
- | <doodle title=" | + | <doodle title=" |
* Yes | * Yes | ||
* No | * No | ||
Line 521: | Line 545: | ||
Secondary vote (choice with the most votes is picked): | Secondary vote (choice with the most votes is picked): | ||
- | <doodle title=" | + | <doodle title=" |
* Yes | * Yes | ||
* No | * No | ||
Line 528: | Line 552: | ||
==== If you voted no, why? ==== | ==== If you voted no, why? ==== | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
+ | - Other | ||
- | <doodle title=" | + | <doodle title=" |
* 1 | * 1 | ||
* 2 | * 2 | ||
Line 544: | Line 569: | ||
* 6 | * 6 | ||
* 7 | * 7 | ||
+ | * 8 | ||
</ | </ | ||
rfc/match_expression.txt · Last modified: 2020/05/09 15:59 by ilijatovilo