-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named anonymous functions #18163
Comments
Since 8.4 closures have better names than just This feature really seems just strange to me, I don't know how likely recursive anonymous functions are, and even then just improving the behaviour of the |
More specifically: They refer to the parent function + line number. Only top-level closures refer to the filename (because the file effectively is the parent function). see https://github.com/php/php-src/blob/master/Zend/tests/closures/closure_065.phpt |
And for the proposal at hand, there is this RFC: https://wiki.php.net/rfc/closure_self_reference |
nice. nice. closing. |
Closures also carry context through captured variables, so Or this, although this looks pretty stale. |
Actually, this can be solved rather simply with a |
Description
Javascript support naming anonymous functions, letting the function refer to itself for recursion without polluting the surrounding scope. And it provides better stack traces. For example:
outputting
Would be nice if PHP could support it too. Like
printing
Benefits:
The text was updated successfully, but these errors were encountered: