Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66034 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58876 invoked from network); 20 Feb 2013 09:08:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2013 09:08:05 -0000 Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:58956] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/37-19387-37294215 for ; Wed, 20 Feb 2013 04:08:04 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 4889770003CC; Wed, 20 Feb 2013 09:08:00 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id RexdNZn22xEZ; Wed, 20 Feb 2013 09:07:59 +0000 (WET) Received: from nebm.ist.utl.pt (unknown [IPv6:2001:690:2100:4::58:1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id CE3E87000439; Wed, 20 Feb 2013 09:07:59 +0000 (WET) Received: from localhost ([127.0.0.1] helo=nebm.ist.utl.pt) by nebm.ist.utl.pt with esmtp (Exim 4.72) (envelope-from ) id 1U85eh-0004ZV-OB; Wed, 20 Feb 2013 09:07:59 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 20 Feb 2013 10:07:59 +0100 To: Stas Malyshev Cc: Derick Rethans , Organization: =?UTF-8?Q?N=C3=BAcleo_de_Engenharia_Biom=C3=A9dica_do_Insti?= =?UTF-8?Q?tuto_Superior_T=C3=A9cnico?= In-Reply-To: <51248C24.4070609@sugarcrm.com> References: <1867201214.20130215192512@cypressintegrated.com> <51248C24.4070609@sugarcrm.com> Message-ID: X-Sender: glopes@nebm.ist.utl.pt User-Agent: RoundCube Webmail/0.8-rc Subject: Re: [PHP-DEV] Questions regarding DateTimeImmutable From: glopes@nebm.ist.utl.pt (Gustavo Lopes) Em 2013-02-20 9:41, Stas Malyshev escreveu: > There's nothing that "everybody" is > doing - there are tons of different usage patterns, some of them > common, > some incompatible. We need to look on what is more probable - that > people use DateTime as hint for operations that do not modify the > incoming object or that they do modify it and also would put > DateTimeImmutable in this code. No, we do not need to look on what is more probable. It's only when we select this very ill-advised option, that we need to start guessing if people used all the guarantees of DateTime (namely its side-effects) or not. > So on one side we have existing code that would not accept > DateTimeImmutable without extensive modification, To "accept a DateTimeImmutable" is not the same as "no recoverable fatal error when a DateTimeImmutable is passed". You can't possibly know whether passing a DateTimeImmutable is safe without reviewing the code on all the call hierarchy starting from where your DateTimeImmutable is passed. > unless we create the > inheritance, on the other side we have some code that modifies > DateTime > and should be protected from passing DateTimeImmutable - but there's > no > such code yet since nobody passes DateTimeImmutable anywhere yet, so > we > don't make any problem for existing code. "[C]ode that modifies DateTime and should be protected from passing DateTimeImmutable" DOES exist already. Saying that it's not a problem for existing code because no one passes DateTimeImmutable is a misleading statement -- it assumes codebases exist in isolation. But current libraries that take DateTime will still be used in 5.5; in fact, that's the basis of your whole argument for this choice. > I find it highly likely that majoirty of DateTime users don't care if > it's mutable or not since they either don't change it (most frequent > use > case) or use something like $foo = $bar->modify("+1 day"); and never > rely on the fact that $bar was modified. Of course, I have no data > about > how many but I find it highly likely that many users simply don't > care > about the difference. Here is some data: http://code.google.com/codesearch#search/&q=%5C$date-%3Emodify%20lang:php&type=cs&sq= As you can see, your assumption is false. In the majority of cases, there is no assignment. -- Gustavo Lopes