On 19/09/12 20:21, Steve Clay wrote:
On 9/19/12 2:01 PM, Andrew Faulds wrote:
Some other ideas:

$cb = (callable) $obj->bar;
Ah, but (callable) that won't work for global functions, since (callable) is a cast, and

(callable) is not usable as a cast (at least in 5.4.7):

$a = (callable)'str'; // Parse error: syntax error, unexpected 'callable' (T_CALLABLE)

This could work, and it makes sense to me at least.


$cb = {mysql_real_escape_string};
$cb = &{mysql_real_escape_string};
These notations are just horrible.

PHP has recently introduced ::class to resolve a classname (namespace Foo; A::class // Foo\A). The “::” was originally a resolution operator for calls, but now, it is also used for names (which sounds good for me). Here, you propose the new notation ::function, which can be understood as: “resolve this function or method as a callable”. We stay in a resolution context. It is consistent regarding to the evolution of this operator.

Another consistent notation is the cast: (callable) $obj->bar;.

However, having { } around with & is absolutely horrible. It is an awful blend between references and dynamic variables, it is not consistent and error-prone when reading.

Cheers :-).

--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/

PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/

Member of HTML and WebApps Working Group of W3C
http://w3.org/



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to