Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66732 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45582 invoked from network); 21 Mar 2013 00:50:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Mar 2013 00:50:29 -0000 Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.77 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.77 blu0-omc2-s2.blu0.hotmail.com Windows 2000 SP4, XP SP1 Received: from [65.55.111.77] ([65.55.111.77:17801] helo=blu0-omc2-s2.blu0.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 15/10-43408-4595A415 for ; Wed, 20 Mar 2013 19:50:29 -0500 Received: from BLU0-SMTP127 ([65.55.111.71]) by blu0-omc2-s2.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 20 Mar 2013 17:50:26 -0700 X-EIP: [3ehJ5ptoCu+5Mo7ZEmfGZWNw/9Qw3syd] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Received: from bob-weinands-imac.fritz.box ([78.141.134.76]) by BLU0-SMTP127.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 20 Mar 2013 17:50:23 -0700 Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) In-Reply-To: <51436105.4040605@sugarcrm.com> Date: Thu, 21 Mar 2013 01:50:21 +0100 CC: PHP List Developers Mailing Content-Transfer-Encoding: quoted-printable References: <51432E01.7090502@mrclay.org> <51433530.5040707@gmail.com> <51436105.4040605@sugarcrm.com> To: Stas Malyshev X-Mailer: Apple Mail (2.1499) X-OriginalArrivalTime: 21 Mar 2013 00:50:23.0819 (UTC) FILETIME=[122469B0:01CE25CE] Subject: Re: [PHP-DEV] Could we kill call_user_func? From: bobwei9@hotmail.com (Bob Weinand) Am 15.3.2013 um 18:57 schrieb Stas Malyshev : > Hi! >=20 >> why not enable then this "getCallback()();"? >=20 > There's an RFC for that: https://wiki.php.net/rfc/fcallfcall > but it has some edge cases which I didn't have time to figure out yet. Is it possible to add this alternative rule for function_call in = zend_language_parser.y: parenthesis_expr { zend_do_begin_dynamic_function_call(&$1, 0 = TSRMLS_CC); } function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$3, = 0, $2.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); = } So that you can write ($this->closure)(); (for invoking Closures instead = of first assigning it, then calling the Closure or writing = $this->closure->invoke()) Or write (getCallback())(). There should be then no edge cases as it is = properly delimited by the parenthesis. I've shortly tested this with no new bugs. Short example: function a () { return "b"; } function b () { return "c"; } print (a())()."\n"; // prints c function a () { return function () { print "a\n"; }; } (a())(); // prints a I also think this with parenthesis around it it is clearer what's being = done: the first part evaluated and then the second executed. (If I would = have to choose I would prefer the parenthesis...) Bob Weinand p.s.: I'm wondering why, with this little patch, (function () { print = "a"; })(); is throwing a fatal error telling me a function name must be = a string while ($temp =3D function () { print "a"; })(); is working = perfectly?! (I think this is the condition which fails: = http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_vm_def.h#2676, but I'm not = 100% sure and now I'm too tired to investigate further into it...)=