Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97375 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30532 invoked from network); 12 Dec 2016 18:44:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Dec 2016 18:44:48 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.86 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.86 mx105.easyname.com Received: from [77.244.243.86] ([77.244.243.86:57253] helo=mx207.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/DD-27518-D10FE485 for ; Mon, 12 Dec 2016 13:44:48 -0500 Received: from cable-81-173-133-127.netcologne.de ([81.173.133.127] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cGVac-0006n1-Vu; Mon, 12 Dec 2016 18:44:43 +0000 Reply-To: internals@lists.php.net References: To: =?UTF-8?Q?Silvio_Mariji=c4=87?= , internals@lists.php.net Message-ID: <2c979395-7b5c-f98e-57a4-ee8b8bd33e74@fleshgrinder.com> Date: Mon, 12 Dec 2016 19:44:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV][RFC][DISCUSSION] - Immutable classes and properties From: php@fleshgrinder.com (Fleshgrinder) On 12/11/2016 5:57 PM, Silvio Marijić wrote: > Hi, > > Discussion is open for following rfc https://wiki.php.net/rfc/immutability > > Cheers > -1 from my side for all the things previously mentioned. The copy-on-write topic must be solved along with the introduction of immutable classes or we end up with this being implemented and not way to mutate them in a controlled fashion. Also -1 on the proposed `copy` or `modify` function. Not only does it seem to allow anyone to mutate the immutable object, it also requires magic strings of the property names. No usage search, no refactoring, no ... I still strongly believe that `__clone` should be made `private` or `protected` for immutable classes to avoid useless cloning. After that we either stick to cloning as we currently do in our `with*` methods or we provide a keyword that changes the behavior of a method. I also propose to use `data` or `value` instead of `immutable` as the class modifier keyword. Its shorter and properly as well as fully communicates what kind of object we are building. -- Richard "Fleshgrinder" Fussenegger