Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63166 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2078 invoked from network); 19 Sep 2012 18:01:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2012 18:01:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.134 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.134 oxmail.registrar-servers.com Received: from [64.22.89.134] ([64.22.89.134:43733] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 04/F0-15057-1980A505 for ; Wed, 19 Sep 2012 14:01:54 -0400 Received: from [192.168.0.200] (5ad4bfa1.bb.sky.com [90.212.191.161]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 07E42F0026; Wed, 19 Sep 2012 14:01:49 -0400 (EDT) Message-ID: <505A085E.1050808@ajf.me> Date: Wed, 19 Sep 2012 19:01:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Steve Clay CC: PHP Internals References: <50593266.5010802@mrclay.org> <5059FE96.7080406@ajf.me> <505A074C.70501@mrclay.org> In-Reply-To: <505A074C.70501@mrclay.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: alternative callback syntax From: ajf@ajf.me (Andrew Faulds) 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/