Hi

Am 2024-10-30 09:31, schrieb Alexandru Pătrănescu:
So, why not allow capturing, since anyway the only place to capture are
constants and static variables?

Static variables already support arbitrary expressions since https://wiki.php.net/rfc/arbitrary_static_variable_initializers. The RFC initially mentioned static variables as a place where only const-expr would be accepted, but I removed that once I remembered about that other RFC.

And this way we could have short closures with auto-capture.
If there are some technical reasons for not doing that, can we have written
in the RFC?

As stated in the RFC: This constraint is consistent with not supporting variables in constant expressions. Capturing a variable is effectively the same as reading a variable. It makes no sense to support one, but not the other.

Best regards
Tim Düsterhus

Reply via email to