Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46831 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66865 invoked from network); 20 Jan 2010 02:28:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2010 02:28:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=gwynne@darkrainfall.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=gwynne@darkrainfall.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain darkrainfall.org from 208.97.132.81 cause and error) X-PHP-List-Original-Sender: gwynne@darkrainfall.org X-Host-Fingerprint: 208.97.132.81 caiajhbdcaib.dreamhost.com Linux 2.6 Received: from [208.97.132.81] ([208.97.132.81:43136] helo=homiemail-a38.g.dreamhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/8A-29385-E5A665B4 for ; Tue, 19 Jan 2010 21:28:47 -0500 Received: from moonstar.home (pool-96-252-5-186.bstnma.fios.verizon.net [96.252.5.186]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by homiemail-a38.g.dreamhost.com (Postfix) with ESMTP id 12A6FD4AEF; Tue, 19 Jan 2010 18:28:42 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii In-Reply-To: <20100119225448.GG3978@phcomp.co.uk> Date: Tue, 19 Jan 2010 21:28:40 -0500 Cc: Stanislav Malyshev , Daniel Convissor , PHP Internals List Content-Transfer-Encoding: quoted-printable Message-ID: <18C2D4B7-D346-48E7-AC34-BA2550AA7524@darkrainfall.org> References: <4B54FC87.8070106@zend.com> <4B55EE56.8040104@lerdorf.com> <4B55FA44.1060601@zend.com> <20100119190836.GA17124@panix.com> <4B5608B2.8050308@zend.com> <20100119195724.GA5597@panix.com> <4B561191.2040700@zend.com> <20100119225448.GG3978@phcomp.co.uk> To: Alain Williams X-Mailer: Apple Mail (2.1077) Subject: Re: [PHP-DEV] function call chaining From: gwynne@darkrainfall.org (Gwynne Raskind) On Jan 19, 2010, at 5:54 PM, Alain Williams wrote: >>> $eep->oop()->ork()->ah()->ah(); >>>=20 >>> the newcomer will have to spend significant time rummaging around = the >>> source code to figure out what classes are involved. >> As opposed to: >> $oop =3D $eep->oop(); >> $ork =3D $oop->ork(); >> $ah =3D $ork->ah(); >> $ah2 =3D $ah->ah(); >>=20 >> where it instantly becomes crystal clear! Come on, this argument of = "I=20 >> could read any code without ever knowing anything about anything but = you=20 >> feature broke it" is getting really stale. You couldn't, and the = feature=20 >> changed nothing. > +1 >=20 > At least with $eep->oop()->ork()->ah()->ah() you don't have = stray/unwanted > variables hanging round to confuse (or be misused) later. +1 It also supports the "allocation is not initialization" (or anti-RAII) = pattern found in languages like Objective-C: Objective-C: String *s =3D [[String alloc] initWithFormat:@"I'm a little teapot, %@ = and %@", @"short", @"stout"]; PHP: $s =3D (new String)->sprintf("I'm a little teapot, %s and %s", "short", = "stout"); (Obviously a very, very contrived example, meant only to illustrate the = pattern.) -- Gwynne