Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67928 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5506 invoked from network); 27 Jun 2013 09:13:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2013 09:13:31 -0000 Authentication-Results: pb1.pair.com header.from=peter.e.lind@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=peter.e.lind@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.180 as permitted sender) X-PHP-List-Original-Sender: peter.e.lind@gmail.com X-Host-Fingerprint: 209.85.217.180 mail-lb0-f180.google.com Received: from [209.85.217.180] ([209.85.217.180:60782] helo=mail-lb0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/6A-51393-9320CC15 for ; Thu, 27 Jun 2013 05:13:30 -0400 Received: by mail-lb0-f180.google.com with SMTP id o10so284744lbi.11 for ; Thu, 27 Jun 2013 02:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=eyhXa/EcDVxM3wA9A1DtUiZuYLa6Ffizfb7rq2vtC+Q=; b=LHoPX4xJr8EhgZYGz1jKuBLNZVzbiBI9sCKebC+ZuTn5+rtELFKi4EYICThtSjC9YO fDZyvMWmxTQ9U2EmbElbv7+vVqTwS2DUfLS3wOXpw5jvthdkmOSIeRj82PV3OQENujPo aE4SUbQhrWYz0AHYPekhq3kBFJe9PMT7vnME/hCkA5kfl3sDvI1tTLUBDK5tvJ6SXX+m sa5mLdrk/v1lq2RBzE5qTX4LBCS2blQ2M6cBuVn7Uq34HdzNLVsg0Rw/huL7/f/vExkA QyqTKj8wWqLHz9gjqbyiObSzQfJMZTzJMb13PPdjf23pS6AbXNFk+5w+a8YLB1nJeLtR bvbw== X-Received: by 10.152.37.138 with SMTP id y10mr3725796laj.40.1372324406121; Thu, 27 Jun 2013 02:13:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.169.67 with HTTP; Thu, 27 Jun 2013 02:13:05 -0700 (PDT) In-Reply-To: References: Date: Thu, 27 Jun 2013 11:13:05 +0200 Message-ID: To: Tom Oram Cc: Richard Quadling , PHP internals Content-Type: multipart/alternative; boundary=089e0141abf4be58bf04e01f2cf8 Subject: Re: [PHP-DEV] RFC Proposal: New assign value operator From: peter.e.lind@gmail.com (Peter Lind) --089e0141abf4be58bf04e01f2cf8 Content-Type: text/plain; charset=UTF-8 On 27 June 2013 11:04, Tom Oram wrote: > Hi Richard, > > Thanks for your reply, the main reason would be operator overloading rather > than the typecasting example, the typecasting version is more for > consistency. I am also fairly that there might be situations where it would > be useful to set the value of a scalar while preserving the time and save > the need for checking the type first, however I do admit I can't think of a > concrete example. > > The main thing I was thinking is I often find myself writing things like: > > $obj->set(2); > > $obj->setValue(5); > > $obj->setX(4); > > Where the object only really represent a single value, examples are things > like EmailAddress class, ZipCode class, MoneyValue class, etc. > What's the reason you're not doing: $obj = new EmailAddress('me@example.com'); or $obj = new Money('16.99', new MoneyType('USD')); ... actually, email is the only one of the above mentioned classes, that could have just one value (neither zip code nor money make sense without context, as zip codes and money depend on locale). That's an aside though. Main question being: are you arguing for operator overloading in PHP when you should just use better constructors? Regards Peter -- WWW: plphp.dk / plind.dk CV: careers.stackoverflow.com/peterlind LinkedIn: plind Twitter: kafe15 --089e0141abf4be58bf04e01f2cf8--