Re: RFC: Support Closures in constant expressions
| From: | Tim Düsterhus | Date: | Mon, 04 Nov 2024 13:16:23 +0000 |
| Subject: | Re: RFC: Support Closures in constant expressions | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-125905@lists.php.net to get a copy of this message | ||
Hi
Am 2024-11-04 13:33, schrieb Rob Landers:
Perhaps? That's the question I am asking. Given that this is not a valid PHP program as of now, it would as least be debatable how this is supposed to work. It gets funnier once you want to support variables in the general case (which I consider a necessary companion to support variable capturing):What would you expect the semantics of that script to be?Isn't this semantically equivalent to:
class Foo {
public function __construct(&$out) {
$out = 'out';
}
}
function foo(
string $bar,
string $baz = new Foo($bar),
) {
var_dump($bar, $baz);
}
To be clear: We do not intend to solve this question with this RFC. These examples are just intended to highlight the (semantic) complexities of supporting variables within const-expr.
Best regards
Tim Düsterhus