Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112824 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63644 invoked from network); 10 Jan 2021 00:56:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jan 2021 00:56:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2A2271804A8 for ; Sat, 9 Jan 2021 16:33:35 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 9 Jan 2021 16:33:34 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D6F6921CC for ; Sat, 9 Jan 2021 19:33:32 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Sat, 09 Jan 2021 19:33:33 -0500 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=fm1; bh=nVv4Ax2D6OmpJJHmoTNFc7uzbpo36j7q88pt7hOtS gw=; b=CFWWK3kaK/6u9jUW3OZ/ZBYL9fZA3bvXeSfiYmv/au4Ob++VHtVEcedVf zpvi736BfoTE0i2C6A5w5t7p+URWwWX7jCrH1M0dLqtTzgkYelWpMCssGImWsdXL fWnidzB2VmpWws+tC2kqZaXmFir4I2LmNmsW0uaq0YgyXNAFUUnoFt1AeA+cwl4m dUS6G/MANNkc76rwkbFUQeJzhjm300XN/7SumFHhigg+mO8c6LJB9ybw0bR5/oB+ axX4eJzxehjijOQDWboz82nf+sTrasT39R9rNxjeOeEvK86goCFzGdFFH1CvcIQ4 g5E/XF3g0NNBy2CINYih3X+xYAGqg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdegkedgvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnheptdfgtdevgffhjefhffegueeltddtiefhuefgtdeu gfehjeegjedvieettdehffeknecuffhomhgrihhnpehpvggrkhgurdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgr rhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0285714200A2; Sat, 9 Jan 2021 19:33:32 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.1-61-gb52c239-fm-20201210.001-gb52c2396 Mime-Version: 1.0 Message-ID: In-Reply-To: References: <1d0abb04-4987-43a9-85bc-bccc3bd6be9a@www.fastmail.com> <03108284-740a-4a5d-130f-15b2e67e9df9@mabe.berlin> <459d7ff7-e553-dce9-7d43-c3b1e772e572@gmail.com> <7f4fe9ca-1c20-6f69-cef0-a9718af742a3@gmail.com> <30906866-1971-8395-05a0-fd78d054bb89@gmail.com> <34d6a045-f7c3-4a77-8b22-378e84b2d1f9@www.fastmail.com> <12c6939d-14ed-4f7c-b2bc-189307a20f74@www.fastmail.com> Date: Sat, 09 Jan 2021 18:33:10 -0600 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: =?UTF-8?Q?Re:_[PHP-DEV]_Analysis_of_property_visibility,_immutability,_a?= =?UTF-8?Q?nd_cloning_proposals?= From: larry@garfieldtech.com ("Larry Garfield") On Sun, Jan 3, 2021, at 11:29 AM, Olle H=C3=A4rstedt wrote: > > I'll disagree slightly. A language feature should introduce more po= wer than > > it does complexity. Not everything *can* be made absolutely simple,= but the > > power it offers is worth it. I'd say it should minimize introduced > > complexity, relative to the power offered. Complexity ideally is su= per low, > > but it's never zero simply by virtue of being "one more thing" that > > developers need to know how to read. > > > > So in this case, we need to compare the power/complexity of asymmetr= ic > > visibility vs the power/complexity of "immutable... except in these > > situations." I would argue that asymmetric visibility is more > > self-documenting, because it states explicitly what those situations= are. > > > > The other point is that, as noted, "initonly" creates a gap if you h= ave > > properties that are inter-dependent. Those then cannot be made publ= ic-read, > > because that would also mean public-clone-with, and thus allow calle= rs to > > violate property relationships. Asymmetric visibility does not have= that > > problem. >=20 > Can you perhaps be a bit more clear on why initonly/readonly would be > a deal breaker? Seems to me like readonly would cover 80% of > use-cases? Which is to make data-value objects humane (and fast, since= > you don't need getters anymore) to work with. Seems like you're > focusing too much on an edge case here. Maybe we should list the > possibly use-cases? Or at least the main target use-case. >=20 > If an object has invariants that need to hold, just throw an exception= > in __clone to force use with withX() instead? Or, as you suggested, > improve __clone by giving it arguments? >=20 > Olle It took a few days, but I am back with some more concrete examples. I d= ecided to try and convert PSR-7 to the various options considered in my = previous post. Here are the results: https://peakd.com/hive-168588/@crell/object-properties-part-2-examples Along with an analysis of the pros/cons of each. As shown there, `inito= nly` creates backdoors that make any but the most basic cases untennable= . --Larry Garfield