rfc:callable

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:callable [2011/06/07 18:53]
bjori fix title
rfc:callable [2017/09/22 13:28] (current)
Line 3: Line 3:
   * Date: 2011-06-07   * Date: 2011-06-07
   * Author: Hannes Magnusson <bjori@php.net>   * Author: Hannes Magnusson <bjori@php.net>
-  * Status: Under Discussion+  * Status: Implemented in PHP 5.4
   * First Published at: http://wiki.php.net/rfc/callable   * First Published at: http://wiki.php.net/rfc/callable
  
Line 19: Line 19:
  
 The typehint would allow a string with a function name, an array composed of classname/obj+methodname, and a closure. The typehint would allow a string with a function name, an array composed of classname/obj+methodname, and a closure.
 +
 +===== Callable vs Callback =====
 +
 +callback is callable, the opposite could not be true. A string, or a closure, is callable, but the string is not a callback.
 +
 +The documentations already use `array` hinting when a function expects an array, even though it does not type hint on it.
 +The documentations already use `callable` hiting when a function expects a callable instance, even though it does not type hint on it.
 +
 +Furthermore we already have a function called is_callable(), and this new feature will share its implementation.
 +
 +Introducing a different name (i..e callback) will therefore only create more inconsistencies and confusion.
 +
 +The callable typehint reuses the is_callable() logic.
 +
 +===== Initialization =====
 +
 +Only null initialize is allowed, making it consistent with classname typehinting.
 +
  
  
Line 34: Line 52:
  
   * The only arguments against the idea came from Stas, [[http://php.markmail.org/message/hhdjdfo3o34mcj2t?q=callable|making the argument]];   * The only arguments against the idea came from Stas, [[http://php.markmail.org/message/hhdjdfo3o34mcj2t?q=callable|making the argument]];
-    * 'callable' are nothing different then 'balanced binary tree' and 'readable file', and none of them make sense to have typehints for+    * 'callable' is a data structure not unlike 'balanced binary tree' and 'readable file', and none of them make sense have as a part of the language syntax. They belong in userspace.  
-    * A "strict typing error" is hard to handle in user-space gracefully+    * A "strict typing error" is hard to handle in user-space gracefully.
   * Everyone else seem to like the idea, so far.   * Everyone else seem to like the idea, so far.
   * As for the patch itself, Felipe pointed out that the patch is missing an method in ext/reflection to retrieve the typehint information.   * As for the patch itself, Felipe pointed out that the patch is missing an method in ext/reflection to retrieve the typehint information.
 +  * Things to finalize:
 +    * Reflection support
 +    * Arginfo support
  
  
Line 43: Line 64:
  
   * June 7th 2011, Initial writeup   * June 7th 2011, Initial writeup
 +  * July 27th 2011, Added "callable vs callback" and "initialization" section
 +
  
rfc/callable.1307472828.txt.gz · Last modified: 2017/09/22 13:28 (external edit)