rfc:closurefromcallable

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:closurefromcallable [2016/04/23 15:56] – Changed to Closure::fromCallable danackrfc:closurefromcallable [2016/07/05 06:54] – status update krakjoe
Line 1: Line 1:
 ====== PHP RFC: Closure from callable function ====== ====== PHP RFC: Closure from callable function ======
-  * Version: 0.95+  * Version: 1
   * Date: 2016-04-23    * Date: 2016-04-23 
   * Author: Dan Ackroyd, Danack@php.net   * Author: Dan Ackroyd, Danack@php.net
-  * Status: Under Discussion +  * Status: Accepted
   * First Published at: https://wiki.php.net/rfc/closurefromcallable   * First Published at: https://wiki.php.net/rfc/closurefromcallable
  
Line 125: Line 125:
 ==== Performance gain ==== ==== Performance gain ====
  
-Although PHP has a 'callable' type it is quite slow to use compared to other types. This is due to the amount of work that is needed to check whether a 'callable' is actually a valid callable or not. This work needs to be each time the 'callable' parameter is called.+Although PHP has a 'callable' type it is quite slow to use compared to other types. This is due to the amount of work that is needed to check whether a 'callable' is actually a valid callable or not. This work needs to be performed each time the 'callable' parameter is called.
  
 Below are two files that call a function 10,000 times which calls itself recursively 8 times. One version has a callable type for the parameter, the other has Closure as the type. Measuring the number of operations with Below are two files that call a function 10,000 times which calls itself recursively 8 times. One version has a callable type for the parameter, the other has Closure as the type. Measuring the number of operations with
Line 139: Line 139:
 | Difference | 18,942,684 | | Difference | 18,942,684 |
  
-Which is a difference of 1,894 operations per loop.+Which is saving 16% of the operations, or a difference of 1,894 operations per loop or about 230 operations per function call where the callable is passed..
  
  
 ==== Patches and Tests ==== ==== Patches and Tests ====
  
-The function has been implemented in this branch: https://github.com/danack/php-src/tree/closureSimpler The patch is not finished as the error messages need some improvement.+The function has been implemented in this PR: https://github.com/php/php-src/pull/1906
    
    
 ==== Proposed Voting Choices ==== ==== Proposed Voting Choices ====
-As this is a simple function addition with no language changes, the voting will requie a 50%+1 majority to include this in PHP 7.1+As this is a simple function addition with no language changes, the voting will require a 50%+1 majority to include this in PHP 7.1 
 + 
 + 
 +Voting will close at 9pm UTC on the 29th of May 2016. 
 +<doodle title="Accept Closure from Callble? (50%+1 majority required)" auth="Danack" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle>
    
    
rfc/closurefromcallable.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1