Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46823 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13267 invoked from network); 19 Jan 2010 18:30:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2010 18:30:34 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; 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:41868] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/41-29385-84AF55B4 for ; Tue, 19 Jan 2010 13:30:34 -0500 Received: from us-gw1.zend.com (unknown [192.168.16.5]) by il-mr1.zend.com (Postfix) with ESMTP id C0AB8504FE for ; Tue, 19 Jan 2010 20:14:13 +0200 (IST) Received: from [192.168.16.93] ([192.168.16.93]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 19 Jan 2010 10:30:27 -0800 Message-ID: <4B55FA44.1060601@zend.com> Date: Tue, 19 Jan 2010 10:30:28 -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: internals@lists.php.net References: <4B54FC87.8070106@zend.com> <4B55EE56.8040104@lerdorf.com> In-Reply-To: <4B55EE56.8040104@lerdorf.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Jan 2010 18:30:27.0622 (UTC) FILETIME=[7905CC60:01CA9935] Subject: Re: [PHP-DEV] function call chaining From: stas@zend.com (Stanislav Malyshev) Hi! > I don't mind the foo()() syntax, especially now that we have closures. > But people are right, we have a longstanding feature request for > $foo()[0] as well, so if we start down this path of adding chaining, we > should do that one as well and see if any others make sense. As I said, that was next on my TODO (which doesn't make a promise of delivering it soon, that depends on so many external circumstances :) > Not sure the {} expression syntax is needed. What sort of expressions > do you see being useful here that would need the braces? Stuff like > $a[$idx]() works today without needing any extra syntax. Are you This is one of the reasons why I wanted to have ()() to work - you can do $myMethods['foo']() but as soon as you go from that to getMyMethod('foo') you have to have temp vars. It's an ugly style. > thinking along the lines of: > > {strtolower($a[$idx])}() No, that is probably not very useful or nice. Only use I'd see as interesting would be either distinguishing between $foo->method() and ($foo->propertyContainingClosure)() and alike. > or something like that? That would make the "I hate linefeeds and > semi-colons" crowd happy, I guess. That's more about extra statements than about linefeeds and semicolons. People like to speak in full expressive sentences, not. In chunks. Each of which. Expresses only small. Part of. The whole meaning. Of the sentence. You can feel the difference, right? I, personally, felt the need to do ()() as soon as I started playing with closures, since when you do that, you very soon having functions returning closures, and that very soon leads to needing to call whatever function fetching closure returned. Of course, you can get too far with it, just as you can get too far with run-on sentences. Just as in prose, one has to watch his style. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com