Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46836 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48165 invoked from network); 20 Jan 2010 12:05:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2010 12:05:39 -0000 Authentication-Results: pb1.pair.com header.from=grobmeier@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=grobmeier@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.227 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: grobmeier@gmail.com X-Host-Fingerprint: 209.85.220.227 mail-fx0-f227.google.com Received: from [209.85.220.227] ([209.85.220.227:56756] helo=mail-fx0-f227.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/39-29385-191F65B4 for ; Wed, 20 Jan 2010 07:05:38 -0500 Received: by fxm27 with SMTP id 27so4515449fxm.23 for ; Wed, 20 Jan 2010 04:05:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=w6VMkwJptlwt7KQ+ox/LnxEIOe8arNSS3vAENeKCpBo=; b=txtaxUXUaI/mG4dmdJVX0mcRCnbSMU8dTZZ9XRWmXh7LOs47WGKDnCI9mPi+fb2+Dr Ni/GG2KKf4u58WwjXq4ZjOqdmy//7K5XIzPE6vYq2caz4B9DRTTD+IWuEdStJuP0bs7j vSD/RlLuq/AaLzKug3BuBfSIvYRnh7uECQi1I= 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 :content-type:content-transfer-encoding; b=I0ka6gPIrQSCparoVOFPYQbH0D/kPuJZkE+VQ4bVPjsUH5zguayKf4Dg/B4v1muU5L W/YcAvhNgU9UCyPYSK9ZQkxQsj5j97NBN6wNOnD8vvRwzaAblahpDBWUI3ACv70o356Z RGcQBub9fLKq+aqXWxgZfs0+quF0RhOGeFI90= MIME-Version: 1.0 Received: by 10.102.252.26 with SMTP id z26mr4406431muh.44.1263989134102; Wed, 20 Jan 2010 04:05:34 -0800 (PST) In-Reply-To: References: <4B54FC87.8070106@zend.com> <4F.56.22457.408955B4@pb1.pair.com> <4B55D850.8000604@zend.com> <68de37341001190820p486b7c31o5689ab5554b8d260@mail.gmail.com> <4B55E591.8060708@lerdorf.com> Date: Wed, 20 Jan 2010 13:05:14 +0100 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: function call chaining From: grobmeier@gmail.com (Christian Grobmeier) On Wed, Jan 20, 2010 at 11:35 AM, Christian Grobmeier wrote: >>> Why would this imply "dropping" the object? >>> >>> This: >>> =C2=A0 =C2=A0$foo =3D (new bar())->someSetter(); >>> Looks a lot better than this >>> =C2=A0 =C2=A0$foo =3D new bar(); >>> =C2=A0 =C2=A0$foo->someSetter(); >> >> The second version is much clearer. =C2=A0You know exactly what $foo is.= =C2=A0In >> the shortened version you have no idea what $foo is without reading the >> code for the someSetter() method. =C2=A0On first glance I would assume t= hat >> $foo would be the success/failure return of the setter and that the >> object is dropped. I also think that: =C2=A0$foo =3D (new bar())->someSetter(); is assigning the return value of the setter to $foo. I would love to have a language feature like anonymous classes, but if $foo contains the bar-object after this line - wow, how would I hate this. From my understanding both examples should act differently. Rephrased: if one would say, the constructor returns itself as a object, you could call the someSetter() method on the returned object. The return value of someSetter() is then assigned. Having such a language feature could help with having that later: $a =3D new AbstractClass { =C2=A0 =C2=A0public function methodToOverride() { =C2=A0 =C2=A0 =C2=A0 // overriding code =C2=A0 } } i think this already works: $a =3D new MyObject(); $a->setListener( new MyListener() ); but this could then work too $a =3D new MyObject(); $a->setListener( new MyFactory()->createZipCreator() ); As said, I would love such a syntax feature cheers Christian