Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50860 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13589 invoked from network); 5 Dec 2010 19:26:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Dec 2010 19:26:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=jbondc@openmv.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jbondc@openmv.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain openmv.com from 64.15.152.204 cause and error) X-PHP-List-Original-Sender: jbondc@openmv.com X-Host-Fingerprint: 64.15.152.204 mail.ca.gdesolutions.com Received: from [64.15.152.204] ([64.15.152.204:54412] helo=mail.ca.gdesolutions.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/E1-01246-967EBFC4 for ; Sun, 05 Dec 2010 14:26:34 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 260D15D4C; Sun, 5 Dec 2010 14:26:31 -0500 (EST) X-Virus-Scanned: amavisd-new at gdesolutions.com Received: from mail.ca.gdesolutions.com ([127.0.0.1]) by localhost (mail.ca.gdesolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5VUDuZNAwrvz; Sun, 5 Dec 2010 14:26:30 -0500 (EST) Received: from djbondc (modemcable083.208-56-74.mc.videotron.ca [74.56.208.83]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 9B06B5D36; Sun, 5 Dec 2010 14:26:30 -0500 (EST) To: "'Benjamin Eberlei'" , "'Herman Radtke'" Cc: "'Larry Garfield'" , References: <201012050255.54059.larry@garfieldtech.com> <20101205104251.3e0310d5@benny-pc> <20101205184409.3bcf5433@benny-pc> In-Reply-To: <20101205184409.3bcf5433@benny-pc> Date: Sun, 5 Dec 2010 14:26:29 -0500 Message-ID: <002d01cb94b2$51f6cf10$f5e46d30$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcuUpBusv6IWZSibQ2ujDzEjc5FHtgAB0KzA Content-Language: en-ca Subject: RE: [PHP-DEV] Patch: Marking DateTime Instances Immutable From: jbondc@openmv.com ("Jonathan Bond-Caron") On Sun Dec 5 12:44 PM, Benjamin Eberlei wrote: > > 1. Just create a DateTimeValue object that is immutable, not > optimizing PHP to handle it with efficient garbage collection. > 2. One step further, add a "static class DateTimeValue" like syntax > that creates an immutable class. > > Any ideas? Some ideas here: http://www.javalobby.org/articles/immutable/index.jsp A pattern I've been using is ~ interface Immutable {} class DateTime_Immutable extends DateTime implements Immutable { // throw exceptions if attempt to modify... } // Get immutable objects... Objects::getImmutable('Datetime', '2009-01-09'); // returns (Immutable) new DateTime_Immutable('2009-01-09') Objects::getImmutable('Datetime', $param1, $param2, ...); // returns (Immutable) new DateTime_Immutable($param1, $param2, ...)