rfc:structural-typing-for-closures

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
rfc:structural-typing-for-closures [2023/04/20 16:11] nicolasgrekasrfc:structural-typing-for-closures [2023/04/20 16:16] (current) nicolasgrekas
Line 46: Line 46:
  
   * What would be the performance impact of adding this feature to the language, considering the engine would need to verify the closure signatures at runtime? Could this be cached internally?   * What would be the performance impact of adding this feature to the language, considering the engine would need to verify the closure signatures at runtime? Could this be cached internally?
-  * Should reflection know something about this? +  * Should reflection/''class_implements()'' know something about this? We think not at this point because those are defined in the context of nominal typing only. 
-  * In order the achieve the required check, the engine would need to autoload the interface/type at call time. The engine might not be prepared for that.+  * In order the achieve the required check, the engine would need to autoload the interface/type at call time or when using ''instanceof''. The engine might not be prepared for that.
  
 ===== Future Scope ===== ===== Future Scope =====
  
   * Auto-cast closures to interfaces that have a single method that is not necessarily named ''%%__invoke()%%''   * Auto-cast closures to interfaces that have a single method that is not necessarily named ''%%__invoke()%%''
-  * Allow closures to declare the interface they implement as in e.g. ''function () implements FooInterface {}''+  * Allow closures to declare the interface they implement as in e.g. ''function () implements FooInterface {}''. See https://wiki.php.net/rfc/allow-closures-to-declare-interfaces-they-implement
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
rfc/structural-typing-for-closures.1682007088.txt.gz · Last modified: 2023/04/20 16:11 by nicolasgrekas