Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46814 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82638 invoked from network); 19 Jan 2010 17:25:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2010 17:25:06 -0000 Authentication-Results: pb1.pair.com header.from=jared.williams1@ntlworld.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jared.williams1@ntlworld.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ntlworld.com designates 81.103.221.49 as permitted sender) X-PHP-List-Original-Sender: jared.williams1@ntlworld.com X-Host-Fingerprint: 81.103.221.49 mtaout03-winn.ispmail.ntl.com Solaris 10 (beta) Received: from [81.103.221.49] ([81.103.221.49:27148] helo=mtaout03-winn.ispmail.ntl.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 69/7A-29385-EEAE55B4 for ; Tue, 19 Jan 2010 12:25:03 -0500 Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20100119172459.RMPT17277.mtaout03-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com>; Tue, 19 Jan 2010 17:24:59 +0000 Received: from p2 ([82.0.126.169]) by aamtaout03-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20100119172458.QEHC2093.aamtaout03-winn.ispmail.ntl.com@p2>; Tue, 19 Jan 2010 17:24:58 +0000 To: "'Stanislav Malyshev'" , "'PHP Internals'" Date: Tue, 19 Jan 2010 17:26:42 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: <4B54FC87.8070106@zend.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4325 Thread-Index: AcqYnlYVDmfDY+wrT3GXJsnYEYWEkQAjjMwg Message-ID: <20100119172458.QEHC2093.aamtaout03-winn.ispmail.ntl.com@p2> X-Cloudmark-Analysis: v=1.1 cv=1ggfb5FlKZQUfF3vzm9UBYZ2uTfLsbs/8dSljwg5+mE= c=1 sm=0 a=lRBSXoDDAAAA:8 a=LuL0ExIMAAAA:8 a=67BIL_jfAAAA:8 a=mIPgpU8OhmvAhpeNlboA:9 a=1fTZz-LRiZ8gkfvpyjsA:7 a=G_vhu7zAP2Kt-b7cuxdo-RhohPUA:4 a=IZSkqWXhC64A:10 a=jxGWhc5sigMA:10 a=T43CsW2iU-sA:10 a=be8We5Bo7aEA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Subject: RE: [PHP-DEV] function call chaining From: jared.williams1@ntlworld.com ("Jared Williams") References: <4B54FC87.8070106@zend.com> > -----Original Message----- > From: Stanislav Malyshev [mailto:stas@zend.com] > Sent: 19 January 2010 00:28 > To: 'PHP Internals' > Subject: [PHP-DEV] function call chaining > > Hi! > > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > > What it means is that if foo() returns callable value (which > probably should be function name or closure) then it would be > called. Parameters and more than two sets of () work too. > Of course, this is mostly useful for doing closures, and that > was primary drive for implementing it - to make working with > closures and especially function returning closures easier. > What does not work currently is $foo->bar()() - since it is > surprisingly hard to tell parser it's not {$foo->bar}()() - > which of course is not what I want to do. > > The patch is here: http://random-bits-of.info/funcfunc.diff > > What do you think? If somebody has better idea btw - maybe > make something like {foo()}() - and make that work for any > expression inside {} - that might work too. So, what do you think? > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com http://www.zend.com/ > (408)253-8829 MSN: stas@zend.com > > -- > PHP Internals - PHP Runtime Development Mailing List To > unsubscribe, visit: http://www.php.net/unsub.php > I've run into problems with $foo[1](); If the closure attempts to change the value of $foo[1] then PHP complains. So was forced to assign to a temporary variable before hand. $f = $foo[1]; $f(); I guessing foo()() could also suffer from the problem? Jared