Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95980 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28175 invoked from network); 13 Sep 2016 09:58:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2016 09:58:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.214 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.214 mail4-2.serversure.net Linux 2.6 Received: from [217.147.176.214] ([217.147.176.214:58249] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/8B-60695-6CDC7D75 for ; Tue, 13 Sep 2016 05:58:31 -0400 Received: (qmail 6677 invoked by uid 89); 13 Sep 2016 09:58:26 -0000 Received: by simscan 1.3.1 ppid: 6671, pid: 6674, t: 0.1004s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.7?) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 13 Sep 2016 09:58:26 -0000 To: internals@lists.php.net References: <0800a5ca-3d14-c541-1a1a-2574ec802b8c@fleshgrinder.com> <83fa661e-2d3d-6548-a506-fb969be31c0e@garfieldtech.com> <56acc1d9-f424-a460-59be-3a9a1a74b198@fleshgrinder.com> <95832b08-ee80-18c1-a3da-202eed51903e@fleshgrinder.com> <2c115733-8fe4-5230-a9ec-9d5f2cc2b810@garfieldtech.com> Message-ID: Date: Tue, 13 Sep 2016 10:58:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] RFC - Immutable classes From: lester@lsces.co.uk (Lester Caine) On 13/09/16 00:47, Stephen Reay wrote: > Regarding identity, I’m going to refer back to the DateTimeImmutable class. I know its not the same implementation, but honestly I don’t think that matters. Developers use PHP because they generally *don’t* have to worry about the internal details of the engine. > > e.g.: > $d = new DateTimeImmutable(); > $e = $d->add(new DateInterval('PT0S')); > > var_dump($d === $e); // bool(false) ReadOnly DateTimeStamp is the only 'objects' I can currently see a use for in my own code base. CoW makes perfect sense to me but I would not view that as 'clone', simply 'construct a new readonly object'. I've already indicated that I view date/time as a simple 64 bit number, and 'comparable' fits that model nicely except it needs a more flexible TOLERANCE for months. ( And DateTimeImmutable does not work for me but that is because I have raw access to the firebird timestamps ) Just where else do people think 'immutable' objects are essential? Just what is necessary over a 'readonly object'? I'm still trying to get my head around some of the hidden details here. My 'readonly object' assumes the code to handle is a separate class used to view the data, but I assume the sort of object being discussed here is in essence a 'constructionaless' copy of the class? With wriggle room to perhaps make some write code available for some strange reason? I'm still struggling to see just where the 'code' fits in this. If I have a copy of the code in the 'construction' version of the class does the copy also need that code duplicated? -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk