Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63186 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5018 invoked from network); 20 Sep 2012 08:24:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Sep 2012 08:24:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=ivan.enderlin@hoa-project.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ivan.enderlin@hoa-project.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hoa-project.net from 95.130.12.24 cause and error) X-PHP-List-Original-Sender: ivan.enderlin@hoa-project.net X-Host-Fingerprint: 95.130.12.24 host1.trois-doubles.net Linux 2.6 Received: from [95.130.12.24] ([95.130.12.24:58010] helo=host1.trois-doubles.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/61-15057-9D2DA505 for ; Thu, 20 Sep 2012 04:24:58 -0400 Received: from Hwhost2.local (unknown [194.57.88.180]) by host1.trois-doubles.net (Postfix) with ESMTPA id 27940209D40 for ; Thu, 20 Sep 2012 10:24:54 +0200 (CEST) Message-ID: <505AD2D8.8090701@hoa-project.net> Date: Thu, 20 Sep 2012 10:24:56 +0200 Reply-To: ivan.enderlin@hoa-project.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/17.0 Thunderbird/17.0a2 MIME-Version: 1.0 To: internals@lists.php.net References: <50593266.5010802@mrclay.org> <5059FE96.7080406@ajf.me> <505A074C.70501@mrclay.org> <505A085E.1050808@ajf.me> <505A0D3F.3040604@mrclay.org> In-Reply-To: <505A0D3F.3040604@mrclay.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: alternative callback syntax From: ivan.enderlin@hoa-project.net ("Ivan Enderlin @ Hoa") On 19/09/12 20:21, Steve Clay wrote: > On 9/19/12 2:01 PM, Andrew Faulds wrote: >>> Some other ideas: >>> >>> $cb =3D (callable) $obj->bar; >> Ah, but (callable) that won't work for global functions, since=20 >> (callable) is a cast, and > > (callable) is not usable as a cast (at least in 5.4.7): > > $a =3D (callable)'str'; // Parse error: syntax error, unexpected=20 > 'callable' (T_CALLABLE) > > This could work, and it makes sense to me at least. > > >> $cb =3D {mysql_real_escape_string}; >> $cb =3D &{mysql_real_escape_string}; These notations are just horrible. PHP has recently introduced ::class to resolve a classname (namespace=20 Foo; A::class // Foo\A). The =93::=94 was originally a resolution operato= r=20 for calls, but now, it is also used for names (which sounds good for=20 me). Here, you propose the new notation ::function, which can be=20 understood as: =93resolve this function or method as a callable=94. We st= ay=20 in a resolution context. It is consistent regarding to the evolution of=20 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 :-). --=20 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/