rfc:function_referencing
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:function_referencing [2014/08/03 14:57] – ajf | rfc:function_referencing [2014/08/18 16:43] – Unbound scoped closures not permitted by ::call anymore ajf | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Function Referencing as Closures ====== | ====== PHP RFC: Function Referencing as Closures ====== | ||
* Version: 0.1 | * Version: 0.1 | ||
- | * Date: 2014-08-03 | + | * Date: 2014-08-03, latest 2014-08-18 |
* Author: Andrea Faulds, ajf@ajf.me | * Author: Andrea Faulds, ajf@ajf.me | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 43: | Line 43: | ||
$qux = new FooBar(3); | $qux = new FooBar(3); | ||
+ | // Static functions referenced retain their scope | ||
$func = & | $func = & | ||
+ | // Thus it can see the instance variables of $qux | ||
$func($qux); | $func($qux); | ||
$func = & | $func = & | ||
$func-> | $func-> | ||
+ | |||
+ | // Or, if we wish to bind | ||
+ | $func = Closure:: | ||
</ | </ | ||
Line 67: | Line 72: | ||
When a function is referenced in this manner, an unbound, unscoped '' | When a function is referenced in this manner, an unbound, unscoped '' | ||
- | Like the [[rfc: | + | We relax the restriction on unbound scoped closures. This is because if we were to give a static method, it could not be bound (useless as it is an instance method), and we don't know what to bind to ahead-of-time. Thus we create an incomplete closure of sorts, which can be called and probably won't work (much like you can statically call an instance method), or can be bound with '' |
- | Because the '' | + | Because the '' |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 90: | Line 95: | ||
A branch which implements this with a test which incorporates the Closure:: | A branch which implements this with a test which incorporates the Closure:: | ||
- | |||
- | ===== Implementation ===== | ||
- | After the project is implemented, | ||
- | - the version(s) it was merged to | ||
- | - a link to the git commit(s) | ||
- | - a link to the PHP manual entry for the feature | ||
===== References ===== | ===== References ===== | ||
Line 101: | Line 100: | ||
* [[https:// | * [[https:// | ||
* [[rfc: | * [[rfc: | ||
- | |||
- | ===== Rejected Features ===== | ||
- | Keep this updated with features that were discussed on the mail lists. |
rfc/function_referencing.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1