Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115262 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83544 invoked from network); 1 Jul 2021 15:05:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Jul 2021 15:05:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9B638180502 for ; Thu, 1 Jul 2021 08:25:39 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 1 Jul 2021 08:25:39 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B0F6D5C00EC for ; Thu, 1 Jul 2021 11:25:38 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Thu, 01 Jul 2021 11:25:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=hGt/0yD92SenQK39IiOzV8FK0rAlGov550WRneuES Ao=; b=QBaxkaAO4B8EpTPN17+jmI93PMR7hZkdsNkAOxj2a8CK5NF7ihzmg/XTy Mi5UcILmb+OIgO9FWGV0L+1mLLZBShoQaIUErPD+tQd6ulhl+Uz7TDUsXCrGqoAS lemD3zZW4Zne60vsLt9Y8dnNrgI84FM2mIrZF4Rqwll/D5TJXexwT3PETA7gkEVB pclUUKvtB+YFlLEFMT1MlVi080fN32SsL1q+SeM6A49CLsPT6hz9ndfynl2zkD3N KoO4TiRzUcUOywDM7CLh9FjrZBlSD+zyWpV6Xn2MCJ0pok6YUbLbTADDpZy0PYdS 9022m92zrgj9fvsqupjJbbJzjG1yw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeiiedgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 647AEAC0076; Thu, 1 Jul 2021 11:25:38 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-530-gd0c265785f-fm-20210616.002-gd0c26578 Mime-Version: 1.0 Message-ID: In-Reply-To: References: Date: Thu, 01 Jul 2021 10:25:18 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] Readonly properties From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jul 1, 2021, at 9:49 AM, Pierre wrote: > Le 01/07/2021 =C3=A0 16:38, Nicolas Grekas a =C3=A9crit=C2=A0: > > Hi NIkita, > > > > I voted against the proposal because it doesn't work with cloning at= all. > > > > Cloning is a critical feature of stateful objects, and we should sol= ve it > > the same version that introduces readonly IMHO. > > > > If we figure out that we can't agree on a sensible improved behavior= for > > cloning, we're going to be in a dead-end with readonly. > > > I respectfully disagree. >=20 > Having readonly properties and immutable objects is a must have, but=20= > changing property of an object while cloning, not so much. There's man= y=20 > case where readonly properties will be valuable where you never need t= o=20 > clone your objects. Actually, cloning objects is not something you do=20= > every day. >=20 > Please note that I agree with you that advanced / flexible clone=20 > semantics would be a nice to have, but I don't see the lack of it=20 > blocking for readonly properties. >=20 > I personally don't have any real use case where I couldn't implement=20= > withers on my objects doing the same than dedicated advanced clone=20 > semantics. Could you please provide some real world examples ? People=20= > could change their minds if they could see why it's so blocking for yo= u. >=20 > Regards, The most famous use case right now for with-er objects is PSR-7, which i= s where the naming convention comes from. I cannot say how widely used = it is outside of FIG-inspired value objects, but I am pretty sure it is = used. The key point is that you rarely need to clone service objects; value ob= jects, however, you have to clone if you want to mutate. Look at any PS= R-7 pipleline. By design, it calls $request->withBlah($newBlah) a lot, = and returns a new object. That's the model that we want to support, and= make *easier* to do, but the readonly flag makes *harder* to do than th= e status quo today. (See my previous post on the subject in the last th= read.) There are use cases for readonly that don't require cloning. For those,= it's useful. I personally think asymmetric visibility would render rea= donly unnecessary and redundant, but Nikita disagrees, and he's the one = writing the code so... :-) The best case scenario is by 8.2 we end up with asymmetric visibility an= d clone-with, and combined with readonly we get a huge array of options = for how to lock down value objects and still make them evolvable. The w= orst case scenario is we find that readonly cannot be extended to suppor= t clone-with for some hand-wavy engine reasons, at which point it become= s largely vestigial in favor of asymmetric visibility and clone-with. --Larry Garfield