Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97360 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56643 invoked from network); 12 Dec 2016 00:16:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Dec 2016 00:16:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=marijic.silvio@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marijic.silvio@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.174 as permitted sender) X-PHP-List-Original-Sender: marijic.silvio@gmail.com X-Host-Fingerprint: 209.85.223.174 mail-io0-f174.google.com Received: from [209.85.223.174] ([209.85.223.174:32879] helo=mail-io0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/B3-27518-16CED485 for ; Sun, 11 Dec 2016 19:16:34 -0500 Received: by mail-io0-f174.google.com with SMTP id d9so145058565ioe.0 for ; Sun, 11 Dec 2016 16:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=JB70MFRJa5KjEOjbfLga4OcAOzS3qLssSp1WVat2qcs=; b=De6eygD//3ZHumXPJxBDU1Tc96TOiaPALw4CW6ypZ7HalkNVRwq6kv+hg0106p8H+s RyL5dXeWs2OPwZ44k2m0w05x+nEOSnVeMFmDim1CLipGWxaxxp7BYI/+wjAQH3tFVisD ijxizGgOzTdSRYhr0ghGP8OgKazkq7jKapfRsbCNtFMTxeL4aYmfcRpljFjh6d6W/Ibm rZFDERLVbMKNb6/m5QCq7DmHxKkeasAL0btzIugbFhPDHZy+Kynd9fzz/+zU4PumFUMQ wmCPi1Ec/TzmthLOaxbb/JbNI+n+P6vaev64oC6paM2MdtTPsfTB9Nhpf344E83EKI3x icmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=JB70MFRJa5KjEOjbfLga4OcAOzS3qLssSp1WVat2qcs=; b=eC4edRcWrhM7Ck9grOuVqi9Exheyq9cClRq0CVZ6VT4BCd777tDeaujBLSgSs1Fipp NHQy6E3laQbXvcbFO5z3bI4FQL9z0+JILIh+do/Qv3tZ2h+2Wg6fLJjX3chUaSCxRYu4 KGVSydXTE9+W0V3FWGWspkEAj7b3PfUe9hTmcPSwx66VbYE5ykCc9AMnukUTpLNhWfwj lOaCLDYYVeP8GGnk3AKmNmh75pTT8wDEs0Rb4BCHnx+ZxL0lM5N1FUk1EXLzOLne8aYs XRGHyv1lVmTyZFdMPKdO0w0BNYGHzOhnEaDg/BZL2ffrli7K3W/LvjBkpG9CeCPvkSxR Y8/Q== X-Gm-Message-State: AKaTC036tThkUQ2PLRJZai9Jq6Z4ioS/u7TTbSpi6mt4L2fYPHTdKCxMAnV8hk3u/lEjpneTfYCk9654UPAo3w== X-Received: by 10.36.0.137 with SMTP id 131mr15606496ita.1.1481501790896; Sun, 11 Dec 2016 16:16:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.110.142 with HTTP; Sun, 11 Dec 2016 16:16:30 -0800 (PST) In-Reply-To: References: <1807f949-81d3-f2c4-8706-0fdade3ea51d@garfieldtech.com> <4635ac4b-844a-b023-5ad9-e8524a156404@texthtml.net> Date: Mon, 12 Dec 2016 01:16:30 +0100 Message-ID: To: Larry Garfield Cc: PHP Internals List , Mathieu Rochette Content-Type: multipart/alternative; boundary=001a11c14280fb0aa205436b037c Subject: Re: [PHP-DEV][RFC][DISCUSSION] - Immutable classes and properties From: marijic.silvio@gmail.com (=?UTF-8?Q?Silvio_Mariji=C4=87?=) --001a11c14280fb0aa205436b037c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This have occurred to me also, I wanted to separate that into two RFC's, but then how we deal with RFC's that depend on each other? 2016-12-12 1:03 GMT+01:00 Larry Garfield : > Assuming this was intended for the list... > > On 12/11/2016 05:55 PM, Mathieu Rochette wrote: > >> Currently the only "unlocked context" for an object is its >> constructor. As discussed previously, that is insufficient. For any >> non-trivial object (more than 1-3 internal properties) creating a new >> one via the constructor only when incrementally building is >> prohibitively difficult. The pattern of with*() methods that spawn >> new objects via clone(), a la PSR-7, needs to be supported. That is: >> >> immutable class Money { >> // ... >> >> public function add(Money $other) : Money { >> $new =3D clone($this); >> $new->amount +=3D $other->amount; >> return $new; >> } >> } >> >> I'm not sure how easily we can denote that sort of case. It's outside >> the __clone() function itself, which is what makes it difficult. >> Without that, though, such immutable objects are of only limited use. >> > > > >> As you said, it has been already been discussed that a method to build >> new altered object from an existing one could be improved. Different >> options were proposed but maybe it's better to start small to get this >> first part right and add this in another rfc ? having everything at the >> same time might makes the rfc more difficult to be accepted >> > > On the contrary, an RFC that doesn't fully solve the issue at hand and > leaves major gaps in place is a poor RFC, and I would expect to be > justifiably voted down. > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Silvio Mariji=C4=87 Software Engineer 2e Systems --001a11c14280fb0aa205436b037c--