Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64247 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43308 invoked from network); 11 Dec 2012 02:17:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2012 02:17:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:54030] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 41/04-16251-9A796C05 for ; Mon, 10 Dec 2012 21:17:15 -0500 Received: from localhost (xdebug.org [127.0.0.1]) by xdebug.org (Postfix) with ESMTPS id D01FCDE13D; Tue, 11 Dec 2012 02:17:08 +0000 (GMT) Date: Tue, 11 Dec 2012 11:17:06 +0900 (JST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Herman Radtke cc: =?UTF-8?Q?=C3=81ngel_Gonz=C3=A1lez?= , Nikita Nefedov , "internals@lists.php.net" In-Reply-To: Message-ID: References: <50C63A7C.8090705@gmail.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323329-421093193-1355192230=:5228" Subject: Re: [PHP-DEV] DateTime improvement From: derick@php.net (Derick Rethans) --8323329-421093193-1355192230=:5228 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 10 Dec 2012, Herman Radtke wrote: > On Mon, Dec 10, 2012 at 11:39 AM, =C3=81ngel Gonz=C3=A1lez wrote: > > On 10/12/12 16:18, Nikita Nefedov wrote: > >> So there had been at least two or three messages (subjects) about > >> DateTime object and everytime there was this problem - people tend to > >> take DateTime object as mutable object and it really is. > >> As long as we know, it's not so good - date is immutable by nature. I > >> don't want to write here why it's so, I will just throw this link: > >> http://www.ibm.com/developerworks/java/library/j-jtp02183/index.html > >> > >> I don't want to change any existing functionality, because some people > >> already use it, but I just wanted to point out that current DateTime > >> class is forcing people to think about it as mutable. > >> My main concerns are DateTime#add() and DateTime#sub(). The problem is > >> - they both change current object and return it. > >> I think we could add methods to DateTime like add() and sub(), let's > >> say plus() and minus(), but they would behave differently in the way > >> that they would return new DateTime objects and won't change current > >> object. > > That will make it even more inconsistent. Yes, that's horrible - and might not even work with the current design. > > You have add() and plus() but one changes the object and the other does= n't. > > > > If we were going to rewrite php or the DateTime class, it could be a > > good idea to make those methods (or its equivalents) not modify the ob= ject. > > But I don't think it'd be a win to do such thing now. > > >=20 > Another option is to make an ImmutableDateTime class. The DateTime > class could actually be changed to inherit the ImmutableDateTime > class. The only extensions on the DateTime class would be the mutable > methods. I'm not really against that, but we do need to use the Date namespace -=20 so DateTimeImmutable. It might be trickier to do than it sounds=20 though... cheers, Derick --=20 http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug Posted with an email client that doesn't mangle email: alpine --8323329-421093193-1355192230=:5228--