-
Notifications
You must be signed in to change notification settings - Fork 8k
[RFC] Closure self-reference #11118
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
base: master
Are you sure you want to change the base?
[RFC] Closure self-reference #11118
Conversation
cdedf1d to
d2cd048
Compare
|
@mvorisek the internals list is where alternatives to RFCs are discussed. Pull-requests are only for technical discussion of the PR. |
33b164d to
5a6b033
Compare
5a6b033 to
9b7f62a
Compare
eec81ee to
8fed167
Compare
|
Just a quick idea... $fibonacci = function (int $n) {
if ($n === 0) return 0;
if ($n === 1) return 1;
return __CLOSURE__($n-1) + __CLOSURE__($n-2);
};I don't tell this proposal is bad and I didn't think about all consequences of my idea. |
|
@dstogov I was thinking about
|
|
Any news regarding this RFC? |
Implementation of https://wiki.php.net/rfc/closure_self_reference
Todo:
$fn->call($class, 3);ZEND_BIND_SELF_REFERENCEis needed somewhere in opcacheZend/Optimizer/sccp.cand/orZend/Optimizer/zend_dfg.c- not sureNotes:
_zend_ast_decl->childshad to be extended to fit this featuremaybe should be merged with static binding AST?
as $fnis placed beforeuse(...)might be sensible to push
asafteruseor even after return type (though latter would look confusing)function(int $a) as $fn use($b) : int {}vsfunction(int $a) use($b) as $fn : int {}vsfunction(int $a) use($b) : int as $fn {}