Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81509 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2155 invoked from network); 1 Feb 2015 00:55:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2015 00:55:26 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.45 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.45 mail-pa0-f45.google.com Received: from [209.85.220.45] ([209.85.220.45:58658] helo=mail-pa0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/E6-01632-D797DC45 for ; Sat, 31 Jan 2015 19:55:26 -0500 Received: by mail-pa0-f45.google.com with SMTP id et14so67301160pad.4 for ; Sat, 31 Jan 2015 16:55:23 -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=iqpNXHL/Rf9LnVkiShYTPzuMOFCD7C+N4fS6guG+slI=; b=c74UROmF/uj/CguvVoLak/78QwnxnrralAybcSBjoVweztBQRDE/2v9yqM8KDtXD7U natjQfYx1e28hs5GMdWkHgRVitorib7hDZx7hyaIYaR4eMq/bIuMdr0ZGzvh2ThjmUFh oLMgBldjBaA1T4HKraO792DmMp+S99radSvKT/IbcLwL9YY/l1VPpKO+Eplv6JYIe1M5 /koU2/jGwgCK0dcL1POoEcdgo4gh5Rs6ie3qWN2GfvUed++QBbBurpn4jWjPCCKB/2O2 LM2EElC+HQBxzUKGQXC+62Zf34fE0ICrdZLr/6eAbKt52Gn+egM0M7Sr1y8CSnparlID J0wA== X-Received: by 10.66.148.161 with SMTP id tt1mr19329039pab.85.1422752123305; Sat, 31 Jan 2015 16:55:23 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id n10sm13521254pdp.18.2015.01.31.16.55.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 31 Jan 2015 16:55:22 -0800 (PST) Message-ID: <54CD7975.8040908@gmail.com> Date: Sat, 31 Jan 2015 16:55:17 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Larry Garfield , internals@lists.php.net References: <54CBC804.7050706@gmail.com> <54CD7668.30301@garfieldtech.com> In-Reply-To: <54CD7668.30301@garfieldtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Immutable variables and objects From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > The with*() methods in PSR-7 are documented to return a new instance, > not modify the existing instance. Yes, there's no way in PHP itself to > force that syntactically, which is why documentation exists. :-) > > Also, in the benchmarks we've run the performance cost of all those new > objects is measured in nanoseconds, ie, small enough that we're not > worried about it. (Hats off to the PHP Internals folks for making that > fast!) It is great that this is fast, but I wonder (maybe off-topic?) why do it? I.e. it is clear that in something like: $a = new Request->withHeaders(...)->withBody(...) ->withEncoding(...)->withETag(...) the intermediate objects are useless and nobody needs 5 new objects when you do it. Am I missing something here? -- Stas Malyshev smalyshev@gmail.com