Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64235 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11766 invoked from network); 10 Dec 2012 19:59:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2012 19:59:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=hermanradtke@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=hermanradtke@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.172 as permitted sender) X-PHP-List-Original-Sender: hermanradtke@gmail.com X-Host-Fingerprint: 209.85.223.172 mail-ie0-f172.google.com Received: from [209.85.223.172] ([209.85.223.172:54037] helo=mail-ie0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/98-60401-A1F36C05 for ; Mon, 10 Dec 2012 14:59:23 -0500 Received: by mail-ie0-f172.google.com with SMTP id c13so10920235ieb.31 for ; Mon, 10 Dec 2012 11:59:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=UPeQygVi1Fmi3mnm5Xc0xDReHPMoN8D1Gy5xat92JS4=; b=rSN0BfOluaDU3Radgx+vItNK3uCc7Svbh1yILieGnUeqXFPRPzoqZdDgPzr+jnuReO VOYHuM0kxKzjdiL3daUp4Df8BxysoNEParMdIdLd/dnf8BY6g/nxHponUpCOR3JcGyvy sqWg6SQ34iWIgQciBDHksKFybv0cjZiHs6eHg1qzTTbIfUaiTf7e5oRhHsf76zAYXwvb Ob9bJJ33RSZjpdFcJRTKNfOUFImlsLDj7UFEIgva6J44tNN6eIaAuFVAMj+/5QtPd28/ R6FZMJ+tGWuTe9xOf41TmVYtyEEy7DQQSA3ZarR8oTAAKvCnprLChvm64aIcF68bX+mS Xr4Q== MIME-Version: 1.0 Received: by 10.50.195.134 with SMTP id ie6mr7320588igc.45.1355169559934; Mon, 10 Dec 2012 11:59:19 -0800 (PST) Received: by 10.64.102.135 with HTTP; Mon, 10 Dec 2012 11:59:19 -0800 (PST) In-Reply-To: <50C63A7C.8090705@gmail.com> References: <50C63A7C.8090705@gmail.com> Date: Mon, 10 Dec 2012 11:59:19 -0800 Message-ID: To: =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= Cc: Nikita Nefedov , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] DateTime improvement From: hermanradtke@gmail.com (Herman Radtke) 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. > 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 obje= ct. > 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. --=20 Herman Radtke hermanradtke@gmail.com | http://hermanradtke.com