Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89269 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6840 invoked from network); 17 Nov 2015 15:42:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2015 15:42:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wm0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:37425] helo=mail-wm0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/51-30130-0DA4B465 for ; Tue, 17 Nov 2015 10:42:09 -0500 Received: by wmww144 with SMTP id w144so31562136wmw.0 for ; Tue, 17 Nov 2015 07:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=hym2hH3KGE9D17g/1V494PJHSN8KB1wNlsXFlc0lNLs=; b=EK7xuLq6Fu0qQBVT638DvZ8zVNGGxCY9pf6mb1BrOBgxxNy5O11g0UsrN0X9XMX0LM OA1ssi34C/tR4Wm60HnFJngUz0CEsU2k2rNgmiMVNNSkpQYGr0ibhIU0GHXqQZHa97+l yeUWicuhO1MnbZt9MRnRyZEzK0EJ/xMXgaV0zl67r9YL7dGKmSGfYkl4hRLXcRuEdPkN r0t4hhHwkNykUAL8L2RM0qyLFKxGfeV5CdZUEbPvIeJUBkKa4+yGR3PxL9LjbcEAL5fm xbjM3LC87+gPj4ap2jAv5uR0F/0c16cNN58rpGp4e50kQ7ahjLB4wsFjZGd4OwMAfSwS H6ew== X-Received: by 10.194.205.162 with SMTP id lh2mr42551291wjc.61.1447774926470; Tue, 17 Nov 2015 07:42:06 -0800 (PST) Received: from [192.168.0.157] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id da10sm17472327wjb.22.2015.11.17.07.42.05 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Nov 2015 07:42:05 -0800 (PST) To: internals@lists.php.net References: <564A547C.9060504@garfieldtech.com> <564A629C.9040709@rochette.cc> <564A69C1.5080208@garfieldtech.com> <2D.66.34372.2A78A465@pb1.pair.com> <564B09A4.3050706@gmail.com> <564B1D0B.1040003@lsces.co.uk> <564B2E66.60601@rochette.cc> Message-ID: <564B4AC1.5020500@gmail.com> Date: Tue, 17 Nov 2015 15:41:53 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <564B2E66.60601@rochette.cc> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Immutable modifier From: rowan.collins@gmail.com (Rowan Collins) Mathieu Rochette wrote on 17/11/2015 13:40: > Indeed, maybe there is a use for a new language construct to help > reduce the boilerplate, but it could be done afterward, the > "everything in the constructor" works fine. If there is too much in > the construct it might be a sign that the class is doing too much and > should be refactored in smaller classes Even with a small number of members, manually reconstructing the object is a nuisance - imagine if you have 4 properties, and 10 "with" methods; not particularly complex for one class. But with "mutable only in the constructor", adding a 5th property would require changing all 10 methods, for absolutely zero gain. It's certainly doable, and if the clone keyword didn't already exist, it would be a reasonable thing to do; but the gains of using "clone" (in terms of code readability and robustness) rather outweigh the gains of marking the class immutable, if the implementation is such that you're forced to choose. Regards, -- Rowan Collins [IMSoP]