Re: Putting the match expression in constant expressions in PHP 8.0 or 8.1
| From: | tyson andre | Date: | Sat, 08 Aug 2020 20:41:56 +0000 |
| Subject: | Re: Putting the match expression in constant expressions in PHP 8.0 or 8.1 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111381@lists.php.net to get a copy of this message | ||
Hi internals,
For unrelated reasons detailed in https://github.com/php/php-src/pull/5951#issuecomment-670969676
,
I'm not planning on continuing work on this due to issues I found thinking about the proposal.
I initially started work on this because the intended behavior seemed underspecified.
"[No objections] from me, though I don't think I'd use it personally." sums up
my current stance on that.
> Such a construct would be compile-time evaluated, so not having a match should result in a
> compile error.
Constants in PHP are lazily evaluated under some circumstances, e.g. class constants in constant
expressions defer evaluation if they refer to other class constants so that classes aren't
unnecessarily autoloaded.
https://github.com/php/php-src/pull/5951/files#diff-96ef697f12a482e3f2a7cb0966a6c5beR46
is an example of UnhandledMatchError in function default params, which are also deliberately not
permanently cached by C.
Compile-time evaluation was something left out of that implementation, but is something that would
get added in
zend_const_expr_to_zval, like it already is for AST_CONDITIONAL.
- Tyson