Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29220 invoked from network); 10 Dec 2012 23:32:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2012 23:32:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=davidkmuir@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=davidkmuir@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.42 as permitted sender) X-PHP-List-Original-Sender: davidkmuir@gmail.com X-Host-Fingerprint: 209.85.210.42 mail-da0-f42.google.com Received: from [209.85.210.42] ([209.85.210.42:54453] helo=mail-da0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/E1-16251-AF076C05 for ; Mon, 10 Dec 2012 18:32:11 -0500 Received: by mail-da0-f42.google.com with SMTP id z17so1365564dal.29 for ; Mon, 10 Dec 2012 15:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=PuaDtcnl8yaMqvdFiPkMzYt5FaJewbx+fsBU/Tc/hnM=; b=l2+VzRPyIWUWc4wnpoAStsgSOy/1otVhVltHvqCvnluTOgohSoOkKt/IoMcSfNTMuZ 2ichY1EC8YGB7llJNUUDDF5ZFtCJ6G6RBBEO692erLnDFWKf1d3KG2/mgSSHPhFHwDKB V3sJJTYJI//zDH5T1I5ZRTmJq4dnAbkGqxkkLw2/X4xLtZB9fVYNTh7et3KK+jmGadMJ Bi0g3mm7tva2qq+x+YV8L9ZRp+TbvAx9ldy+ZlAyR4/uAZfpnBkprtoM54I7cGkrDMz7 mu9Hs+hv+cot72eMEO06fNh21vzhFKwZuskvsPbeBeRj7HExOES1DanA5ImVjLdQy7S9 1sSQ== Received: by 10.69.1.9 with SMTP id bc9mr43138366pbd.61.1355182328143; Mon, 10 Dec 2012 15:32:08 -0800 (PST) Received: from [192.168.1.181] (tmwpho1.lnk.telstra.net. [110.142.207.74]) by mx.google.com with ESMTPS id qt3sm12575809pbb.32.2012.12.10.15.32.05 (version=SSLv3 cipher=OTHER); Mon, 10 Dec 2012 15:32:07 -0800 (PST) Message-ID: <50C670F4.2070001@gmail.com> Date: Tue, 11 Dec 2012 10:32:04 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Herman Radtke CC: =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= , Nikita Nefedov , "internals@lists.php.net" References: <50C63A7C.8090705@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] DateTime improvement From: davidkmuir@gmail.com (David Muir) On 11/12/12 06:59, Herman Radtke wrote: > On Mon, Dec 10, 2012 at 11:39 AM, Ángel González 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. >> You have add() and plus() but one changes the object and the other doesn'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 object. >> But I don't think it'd be a win to do such thing now. >> > 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. > > Would love to see ImmutableDateTime! David