Re: RFC: alternative callback syntax
| From: | Andrew Faulds | Date: | Wed, 19 Sep 2012 18:01:02 +0000 |
| Subject: | Re: RFC: alternative callback syntax | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-63166@lists.php.net to get a copy of this message | ||
On 19/09/12 18:56, Steve Clay wrote:
On 9/19/12 1:19 PM, Andrew Faulds wrote:I completely agree. How about &function_name? Resembles C (function pointers!), and unless I'm getting confused, it isn't currently legal syntax for something else.$cb = & Foo::doSomething; $cb = & foo_doSomething; $cb = & $obj->doSomething; The last looks like a reference to a property, though having verb method names would help distinguish. Not sure if the ambiguity would make this difficult to implement. Oops, good point!
Some other ideas: $cb = (callable) $obj->bar; Ah, but (callable) that won't work for global functions, since (callable) is a cast, and if I try to do:
$cb= (callable) mysql_real_escape_string;I'd actually try to access a constant named 'mysql_real_escape_string' (bad!!)
$cb = callable $obj->bar; $cb = callable::$obj->bar; $cb = $obj->bar::callable; Here's two other possibilities from me:
$cb = {mysql_real_escape_string};
$cb = &{mysql_real_escape_string};
Both are completely illegal just now, I think.
Steve-- Andrew Faulds http://ajf.me/