Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114788 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62019 invoked from network); 8 Jun 2021 18:14:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jun 2021 18:14:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F3667180508 for ; Tue, 8 Jun 2021 11:29:07 -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 out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 8 Jun 2021 11:29:07 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8F74E5C01BD for ; Tue, 8 Jun 2021 14:29:06 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Tue, 08 Jun 2021 14:29:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=ZS8sHs VltNSNKnWJ8seHiLKiWTB03/TRUCFpro6ex4c=; b=QU5NYXRxPFlOQZTX0b3Zf5 gu9WHb8gx5t/1CnqDTmMMFbpdSm9e2ZCzaqvCq2j762qn6zaAEy1CB7O4srgspA0 al6gN6Ht1Ctqz2UFNFyDHoN4A67aQ078v5ibKTo6lGXurNf9aQxlQwMsLa+5VHHt b+51Q/ymFE/lzZsqH5jPBSdTcGjZyGD8YQ5A8rBJJ35poZ4iKSpVB7/AqqHiHbUN SHI+U+rgEYI3i7d5z3kjlCfhg05e3gCSG3zTVawIM4XXFzoL3nzrFEGNlCktDBZM /wnFts8TFlCTCLRm8hXipoK65m/JbH/Gz9+PZZ8np4lhM55uV8NckIuXKUKRG90A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedtledgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepudekffdujefftdekhffgiedthffhgeelgfeigfdt udefveeukeehiedvtdduteeknecuffhomhgrihhnpehgrhgvphdrrghpphenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghr fhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id AEBECAC0062; Tue, 8 Jun 2021 14:29:05 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-519-g27a961944e-fm-20210531.001-g27a96194 Mime-Version: 1.0 Message-ID: <2d64f097-9cf0-449c-9bfa-26bbcdda7002@www.fastmail.com> In-Reply-To: References: <83a9d0ab-60b8-4939-8be9-bdd6ddeb46c5@www.fastmail.com> <9e921668-369c-41f2-a207-856cd098a3f1@www.fastmail.com> Date: Tue, 08 Jun 2021 13:28:04 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Readonly properties From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jun 8, 2021, at 4:18 AM, Nikita Popov wrote: > > (Like, for example, if one had a readonly property but wanted to convert > > it to a custom accessor property... what are the subtle knock on effects > > they have to account for, then? There are almost certainly more of them > > than if switching a property from implicit accessors to explicit accessors, > > although off hand I don't know what they would all be.) > > > > > I think this is a legitimate concern to have, but (under the assumption > > > that we can have only one) it's not easy to say which would be > > preferable. > > > Yes, asymmetric visibility is more widely applicable, but at the same > > time > > > I would expect most applications to be bonafide readonly properties. So > > > while asymmetric visibility is more widely applicable, it's also > > imprecise > > > for the majority use case. Which is better? Of course, my assumption here > > > could also be wrong. > > > > As above, I'd love to get some actual data from the C# community on this. > > Lacking that, we're all just guessing.> > > > Well, I think we can get an approximation like this: > > https://beta.grep.app/search?q=%7B%20get%3B%20private%20set%3B%20%7D&filter[lang][0]=C%23 > { get; private set; } 74,281 results > https://beta.grep.app/search?q=%7B%20get%3B%20%7D&filter[lang][0]=C%23 { > get; } 156,304 results > https://beta.grep.app/search?q=readonly&filter[lang][0]=C%23 readonly > 409,585 results > > Note that the "{ get; }" part includes both readonly properties and > get-only abstract properties, so that one is an overestimate. Using > variants like \{\s+get;\s+private set;\s+\} doesn't change the results > materially. > > Unless my methodology is completely borked, the ratio of readonly to > asymmetric visibility seems to be something like 4:1 even as a conservative > estimate. > > Regards, > Nikita Interesting. I have no particular grounds to challenge your methodology, so I'll accept that C# seems to use readonly much more than asymmetric visibility/accessors. Does C# have a clone-with or equivalent? Even with readonly being useful, I think it's only half the answer without a clean evolvability mechanism beyond "re-type all the fields by hand." CPP removed a ton of that boilerplate, and I'd hate to bring it back. --Larry Garfield