Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46809 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75591 invoked from network); 19 Jan 2010 17:02:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2010 17:02:19 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 216.239.58.186 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 216.239.58.186 gv-out-0910.google.com Received: from [216.239.58.186] ([216.239.58.186:20359] helo=gv-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/F8-29385-995E55B4 for ; Tue, 19 Jan 2010 12:02:18 -0500 Received: by gv-out-0910.google.com with SMTP id n8so67004gve.37 for ; Tue, 19 Jan 2010 09:02:14 -0800 (PST) Received: by 10.103.67.24 with SMTP id u24mr2155961muk.77.1263920533951; Tue, 19 Jan 2010 09:02:13 -0800 (PST) Received: from ?192.168.200.22? (c-98-234-184-167.hsd1.ca.comcast.net [98.234.184.167]) by mx.google.com with ESMTPS id w5sm22734255mue.22.2010.01.19.09.02.12 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 19 Jan 2010 09:02:12 -0800 (PST) Message-ID: <4B55E591.8060708@lerdorf.com> Date: Tue, 19 Jan 2010 09:02:09 -0800 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Eddie Drapkin CC: internals@lists.php.net References: <4B54FC87.8070106@zend.com> <4F.56.22457.408955B4@pb1.pair.com> <4B55D850.8000604@zend.com> <68de37341001190820p486b7c31o5689ab5554b8d260@mail.gmail.com> In-Reply-To: <68de37341001190820p486b7c31o5689ab5554b8d260@mail.gmail.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: function call chaining From: rasmus@lerdorf.com (Rasmus Lerdorf) Eddie Drapkin wrote: > On Tue, Jan 19, 2010 at 11:05 AM, Stanislav Malyshev wrote: >> The second was next on my list, while the first seems to me kind of exotic - >> why create object only to call one method and immediately drop it? Why this >> method is not static then? > > > Why would this imply "dropping" the object? > > This: > $foo = (new bar())->someSetter(); > Looks a lot better than this > $foo = new bar(); > $foo->someSetter(); The second version is much clearer. You know exactly what $foo is. In the shortened version you have no idea what $foo is without reading the code for the someSetter() method. On first glance I would assume that $foo would be the success/failure return of the setter and that the object is dropped. -Rasmus