Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67861 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9309 invoked from network); 26 Jun 2013 12:21:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2013 12:21:46 -0000 Authentication-Results: pb1.pair.com header.from=rstoll@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rstoll@tutteli.ch; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: rstoll@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:38685] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/E4-18025-7DCDAC15 for ; Wed, 26 Jun 2013 08:21:43 -0400 Received: (qmail 18062 invoked from network); 26 Jun 2013 14:21:40 +0200 Received: from 99-206.5-85.cust.bluewin.ch (HELO RoLaptop) (85.5.206.99) by ns73.kreativmedia.ch with (AES128-SHA encrypted) SMTP; 26 Jun 2013 14:21:39 +0200 To: =?utf-8?Q?'Johannes_Schl=C3=BCter'?= Cc: , "'Tom Oram'" , "'PHP internals'" References: <001b01ce7263$da79fec0$8f6dfc40$@tutteli.ch> <1372248825.2410.6.camel@guybrush> In-Reply-To: <1372248825.2410.6.camel@guybrush> Date: Wed, 26 Jun 2013 14:21:39 +0200 Message-ID: <002701ce7267$b5ededb0$21c9c910$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJSSTh9my3sbZMhkjrVJdXZGpMLSwEm5OrRAbRHEOoCNsI+tJgXrNgA Content-Language: de-ch Subject: AW: AW: [PHP-DEV] RFC Proposal: New assign value operator From: rstoll@tutteli.ch ("Robert Stoll") I agree, $price =3D new MoneyValue(29.99); makes more sense and that's = what I questioned in my first email. The benefit is small, I said that as well, and the drawbacks are maybe = bigger as you already outlined. -----Urspr=C3=BCngliche Nachricht----- Von: Johannes Schl=C3=BCter [mailto:johannes@schlueters.de]=20 Gesendet: Mittwoch, 26. Juni 2013 14:14 An: Robert Stoll Cc: RQuadling@GMail.com; 'Tom Oram'; 'PHP internals' Betreff: Re: AW: [PHP-DEV] RFC Proposal: New assign value operator On Wed, 2013-06-26 at 13:54 +0200, Robert Stoll wrote: > As far as I see it, it is kind of an operator overload mechanism for = the assign operator. > This can be useful for small utility classes such as Money, Email etc. >=20 > An example was given: > $price =3D new MoneyValue(); > $price :=3D 29.99; >=20 > Instead of writing something like: > $price =3D new MoneyValue(); > $price->setPrice(29.99); >=20 > The benefit is small, but can lead to better readable code. But since=20 > it is only for the assign operator and not for + - etc., for me the=20 > question remains open why not writing something like this directly: >=20 > $price =3D new MoneyValue(29.99); I see no benefit. It adds a new operator with new semantics which one has to learn to = understand the code and which is hard to Google. Also such objects seem to be value objects, so it should be immutable = thus allowing code like $price =3D new MoneyValue(); $price->setPrice(29.99); looks like bad design. If you have to type $price =3D new MoneyValue(29.99); often you can shorten it use MoneyValue as MV; $price =3D new MV(29.99); sure still longer than :=3D but no new syntax and more explicit. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: http://www.php.net/unsub.php