Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81539 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17705 invoked from network); 1 Feb 2015 18:51:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2015 18:51:20 -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 209.85.212.169 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.169 mail-wi0-f169.google.com Received: from [209.85.212.169] ([209.85.212.169:57403] helo=mail-wi0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FF/13-33325-6A57EC45 for ; Sun, 01 Feb 2015 13:51:18 -0500 Received: by mail-wi0-f169.google.com with SMTP id h11so11753022wiw.0 for ; Sun, 01 Feb 2015 10:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=5ud9eVtdcKXQOx66jiUBhx+y+d/j4bpdNB80ktY2KqA=; b=r6KqcU3BHCXN8kGROiww2fAFGIIQeayeols/tuCaqKyuPMOZSa7WSdvUtd7UkHBICa LLm98UTDoBSE5rMmcGrP2TrJSFOldaQ657vgqx2nBYkNF7KKaO5Mww1VWgxmoFB2GUX1 QI0rAT1O0gyVmO0BXFoY6Y7Hs17p4HoxvE9H1pL7Pk2xYP/fcIJnNPEISjFMpCAeQGNd WLOe6//+itoo5ykVyvhfgNMt8s+730+R0wr2QtqN+c3z7C6udDX420WaibGIow/HW6M/ ZyibJqjPkhDdVtQ2eQ+RV3fGz+ydZwyrRpWQDjZjmBZJyjeFBDqf1+mIwqHqk/I3WuDy og8g== X-Received: by 10.194.108.202 with SMTP id hm10mr36960285wjb.72.1422816674977; Sun, 01 Feb 2015 10:51:14 -0800 (PST) Received: from [192.168.0.2] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id a20sm16338286wic.16.2015.02.01.10.51.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Feb 2015 10:51:14 -0800 (PST) Message-ID: <54CE7589.7060407@gmail.com> Date: Sun, 01 Feb 2015 18:50:49 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: <54CBC804.7050706@gmail.com> <54CD7668.30301@garfieldtech.com> <54CD7975.8040908@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Immutable variables and objects From: rowan.collins@gmail.com (Rowan Collins) On 01/02/2015 01:06, Andrea Faulds wrote: >> the intermediate objects are useless and nobody needs 5 new objects when >> >you do it. Am I missing something here? > I assume the reason for doing this is so you can’t ever modify the object from a distance, you must always create a new one to avoid messing up anything with an existing handle on it. An alternative, which I'm guessing FIG considered and rejected, is having a mutable "builder" object, and require the user to specifically request an immutable object when they're ready to use it: $builder = new RequestBulider; $a = $builder->withHeaders(...)->withBody(...)->getRequest(); $a_prime = $builder->withEncoding(...)->withETag(...)->getRequest(); -- Rowan Collins [IMSoP]