Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50597 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57545 invoked from network); 26 Nov 2010 20:25:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Nov 2010 20:25:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=peter.e.lind@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=peter.e.lind@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: peter.e.lind@gmail.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:38838] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/D0-52610-3D710FC4 for ; Fri, 26 Nov 2010 15:25:56 -0500 Received: by ywe9 with SMTP id 9so1238313ywe.29 for ; Fri, 26 Nov 2010 12:25:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=hN1ciSujhMQSNBSiB5t45jN6Q8t04FJ08KrDrCpStvI=; b=KaR+KsbcnY+JWLMT/mVBq+qa+vBxuyeiuutXD6f36prSMGezCtxxJlHpNRm8Uhlk4X thRdfX63GNa+pdx3xZJ7QSsRV1Ddq0y+q9cv/iF3K/SSdYbeQvhuuch6tUDsyPllQ42w ED/lyO/w7oSn4X/bbakDf8Tumzp3pSClKuS1g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=b4hJxWvneIwHbxo6H1PHlslBE5zpMOlF2rUPz32RGbAgWuN7rpdutJPdvl83Y46j/2 Aa2FB35aPzzu1KRbnEMRJ0zxgq1ZgmqfS5Ltu4q98kiC6gvAf6zGfI5vxmu3qfgPmISK Nz3cipn/XrsnQW+8UAn5OkdzEmf5PLop7yYmM= Received: by 10.90.7.15 with SMTP id 15mr5052300agg.13.1290803152548; Fri, 26 Nov 2010 12:25:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.90.91.14 with HTTP; Fri, 26 Nov 2010 12:25:32 -0800 (PST) In-Reply-To: References: Date: Fri, 26 Nov 2010 21:25:32 +0100 Message-ID: To: Felipe Pena Cc: internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] new foo()->bar() From: peter.e.lind@gmail.com (Peter Lind) On 26 November 2010 20:36, Felipe Pena wrote: > Hi all, > I'm here again to presents another proposal, which adds support for > instantiating a class and calling its methods and accessing its propertie= s > on same command. > > Example: > > > class bar { > =C2=A0public $x =3D 'PHP'; > } > > class foo extends bar { > =C2=A0public function bar() { > =C2=A0 =C2=A0return $this; > =C2=A0} > } > > var_dump(new foo()->bar()->x); // string(3) "PHP" > > ?> > > Other examples which describes the feature at > http://wiki.php.net/rfc/instance-method-call > > Thoughts? It seems fairly handy and I've been in situations where I wanted to do something like that - in fact, I use factories to achieve something similar. However, the more I use it, the more it feels like introducing code smells into my code. You're essentially instantiating an object only to immediately throw it away. That means you don't actually need the object at all, you should probably be looking for static methods or class properties. Trying to avoid statics by introducing a way to instantiate and throw away objects in the same statement feels a lot like reinventing OOP while adding overhead. Anyway, just a personal observation. I generally favour the way that PHP allows you to dig your own grave (i.e. I love the freedom of the language), so as a developer I would probably favour this as well, though I find it mainly a way to introduce hacks. Regards Peter --=20 WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15