Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46789 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29035 invoked from network); 19 Jan 2010 00:27:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2010 00:27:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.185 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.185 il-mr1.zend.com Received: from [212.25.124.185] ([212.25.124.185:46608] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 10/59-22457-C8CF45B4 for ; Mon, 18 Jan 2010 19:27:57 -0500 Received: from us-gw1.zend.com (unknown [192.168.16.5]) by il-mr1.zend.com (Postfix) with ESMTP id 9215650503 for ; Tue, 19 Jan 2010 02:11:40 +0200 (IST) Received: from [192.168.16.93] ([192.168.16.93]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 18 Jan 2010 16:27:51 -0800 Message-ID: <4B54FC87.8070106@zend.com> Date: Mon, 18 Jan 2010 16:27:51 -0800 Organization: Zend Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Lightning/1.0b2pre Thunderbird/3.0 MIME-Version: 1.0 To: 'PHP Internals' Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Jan 2010 00:27:51.0995 (UTC) FILETIME=[3C73B0B0:01CA989E] Subject: function call chaining From: stas@zend.com (Stanislav Malyshev) 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