rfc:functional-interfaces

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
rfc:functional-interfaces [2016/04/17 21:13] krakjoerfc:functional-interfaces [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: Functional Interfaces ====== ====== PHP RFC: Functional Interfaces ======
   * Version: 0.1   * Version: 0.1
-  * Date: 2016-04-17 +  * Date: 2016-04-17
   * Author: krakjoe   * Author: krakjoe
-  * Status: Draft+  * Status: Declined
   * First Published at: http://wiki.php.net/rfc/functional-interfaces   * First Published at: http://wiki.php.net/rfc/functional-interfaces
  
Line 35: Line 35:
 </code> </code>
  
-There is enough information in the code above for the compiler to reason that $cb should implement IFoo, and obviously be a Closure.+There is enough information in the code above for the engine to reason that $cb should implement IFoo, and obviously be a Closure.
  
 The engine generates the appropriate class entry using the closure as the only public method, having easily determined the correct name for that method (there is, and can only be, one possible candidate). The engine generates the appropriate class entry using the closure as the only public method, having easily determined the correct name for that method (there is, and can only be, one possible candidate).
Line 180: Line 180:
   * supports lexical scope   * supports lexical scope
  
-Functional interfaces don'change the definition of an interface and only reuse the definition of a Closure.+Functional interface support does not change the definition of an interfaceand only reuse the definition of a Closure.
  
 ===== Receiving and Invoking Functional Interfaces ===== ===== Receiving and Invoking Functional Interfaces =====
Line 222: Line 222:
 </code> </code>
  
-This means that the receiver (Foo::__construct) can receive, and consumer (Foo::thing) can invoke the interface as if it were a normal object, while the creator of $logger, who must know it is a Closure, can still invoke it as a Closure.+This means that the receiver (%%Foo::__construct%%) can receive, and consumer (Foo::thing) can invoke the interface as if it were a normal object, while the creator of $logger, who must know it is a Closure, can still invoke it as a Closure.
  
 Both methods of invocation are valid in both receiving and declaring contexts. Both methods of invocation are valid in both receiving and declaring contexts.
Line 282: Line 282:
  
 <code php> <code php>
-... +<?php 
-    function () implements self {}; +new class { 
-...+    public function __construct() { 
 +        function () implements self {}; 
 +    } 
 +};
 </code> </code>
- 
-**See 3v4l for this example, the wiki has problems displaying the code.** 
  
 <code>Fatal error: functional interface cannot implement self in /in/MMuD0 on line 4</code> <code>Fatal error: functional interface cannot implement self in /in/MMuD0 on line 4</code>
Line 342: Line 343:
  
 This looks as if ''Interface'' somehow uses ''$thing''. This looks as if ''Interface'' somehow uses ''$thing''.
 +
 +===== Vote =====
 +
 +Voting started on May 15th, ended May 29th 2016.
 +
 +<doodle title="Accept functional interfaces? (2/3+1 majority required)" auth="krakjoe" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 352: Line 362:
  
 ==== To Existing Extensions ==== ==== To Existing Extensions ====
-Extensions will be able to provide implementations of functional interfaces as part of their API.+The API to create functional interface implementations is exported by Zend, and part of the already exported Closure API.
  
 ==== To Opcache ==== ==== To Opcache ====
 Opcache may need a trivial patching. Opcache may need a trivial patching.
- 
-===== Open Issues ===== 
-TBD 
  
 ===== Future Scope ===== ===== Future Scope =====
-This sections details areas where the feature might be improved in futurebut that are not currently proposed in this RFC.+When the concept of functional interfaces is implemented, it may be worth discussing the coercionor explicit cast of callables.
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
Line 375: Line 382:
  
 ===== References ===== ===== References =====
-Links to external references, discussions or RFCs+ 
 +[[http://news.php.net/php.internals/92404|php.internals]]
rfc/functional-interfaces.1460927586.txt.gz · Last modified: 2017/09/22 13:28 (external edit)