Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67859 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5784 invoked from network); 26 Jun 2013 12:13:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2013 12:13:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 config.schlueters.de Received: from [217.114.211.66] ([217.114.211.66:43725] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6A/24-18025-00BDAC15 for ; Wed, 26 Jun 2013 08:13:53 -0400 Received: from [192.168.2.20] (ppp-88-217-78-161.dynamic.mnet-online.de [88.217.78.161]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id A4AFF65133; Wed, 26 Jun 2013 14:13:49 +0200 (CEST) To: Robert Stoll Cc: RQuadling@GMail.com, 'Tom Oram' , 'PHP internals' In-Reply-To: <001b01ce7263$da79fec0$8f6dfc40$@tutteli.ch> References: <001b01ce7263$da79fec0$8f6dfc40$@tutteli.ch> Content-Type: text/plain; charset="UTF-8" Date: Wed, 26 Jun 2013 14:13:45 +0200 Message-ID: <1372248825.2410.6.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: AW: [PHP-DEV] RFC Proposal: New assign value operator From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) 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. > > An example was given: > $price = new MoneyValue(); > $price := 29.99; > > Instead of writing something like: > $price = new MoneyValue(); > $price->setPrice(29.99); > > The benefit is small, but can lead to better readable code. But since > it is only for the assign operator and not for + - etc., for me the > question remains open why not writing something like this directly: > > $price = 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 = new MoneyValue(); $price->setPrice(29.99); looks like bad design. If you have to type $price = new MoneyValue(29.99); often you can shorten it use MoneyValue as MV; $price = new MV(29.99); sure still longer than := but no new syntax and more explicit. johannes