Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26460 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24943 invoked by uid 1010); 10 Nov 2006 11:56:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 24928 invoked from network); 10 Nov 2006 11:56:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Nov 2006 11:56:00 -0000 Authentication-Results: pb1.pair.com header.from=news@sea.gmane.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php-php-dev@m.gmane.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain m.gmane.org designates 80.91.229.2 as permitted sender) X-PHP-List-Original-Sender: php-php-dev@m.gmane.org X-Host-Fingerprint: 80.91.229.2 main.gmane.org Linux 2.5 (sometimes 2.4) (4) Received: from [80.91.229.2] ([80.91.229.2:55462] helo=ciao.gmane.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/16-16675-CC864554 for ; Fri, 10 Nov 2006 06:55:58 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1GiUzB-00077m-MY for internals@lists.php.net; Fri, 10 Nov 2006 12:55:53 +0100 Received: from popeye.ez.no ([85.19.74.66]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 10 Nov 2006 12:55:53 +0100 Received: from sb by popeye.ez.no with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 10 Nov 2006 12:55:53 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: internals@lists.php.net Date: Fri, 10 Nov 2006 12:55:45 +0100 Lines: 31 Message-ID: References: <7c3b2950611091321y649266abs4f3a5bac7187e889@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: popeye.ez.no User-Agent: Thunderbird 2.0a1 (X11/20061109) In-Reply-To: <7c3b2950611091321y649266abs4f3a5bac7187e889@mail.gmail.com> X-Enigmail-Version: 0.94.1.0 Sender: news Subject: Re: [PHP-DEV] Feature request From: sb@sebastian-bergmann.de (Sebastian Bergmann) Dmitry Shirokov wrote: > function foo() > { > return array(1,2,3,4,5,6); > } > > echo foo()[4]; // <---- it that > // or may be (foo())[4] ? > > > // instead of > $var = foo(); > echo $var[4]; > ?> Although I am not a huge fan of method chaining in general (see [1]), I am happy to have it in PHP as it faciliates fluent interfaces [2]. I makes IMHO perfect sense to also allow a similar syntax for arrays. But the implementation should be closed (in the mathematical sense), so that $o->m()[0]->n() also works, for instance, when m() returns an array that has an object with method n() at index 0. -- [1] http://en.wikipedia.org/wiki/Law_of_Demeter [2] http://www.martinfowler.com/bliki/FluentInterface.html -- Sebastian Bergmann http://sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69