Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118373 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11656 invoked from network); 7 Aug 2022 18:45:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Aug 2022 18:45:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 08211180544 for ; Sun, 7 Aug 2022 13:46:40 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 7 Aug 2022 13:46:39 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A185A5C00E0 for ; Sun, 7 Aug 2022 16:46:39 -0400 (EDT) Received: from imap44 ([10.202.2.94]) by compute2.internal (MEProxy); Sun, 07 Aug 2022 16:46:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ollie.codes; h= cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1659905199; x=1659991599; bh=nYZa9aAjnC Ik45IKTQIC9AaHNDyEaZIUkFk4aJ3Jyl8=; b=xOv4GsBgUDI6FiSxset8DQZseq Ik8SnpCEMyj0yhNW8GMq0Lg9k5RGrpnXRaBco0zFYPo4iwajL4nXJzIVFKqO3Pvm c11DMANwFFWCFaloCovY+FTmj6AF2sT1OCSKSQuPZLNaikVS8fnkgTdXSlQyrVE7 Q5D6df62fmcsOJwFTTBoeOJciERpbTbrEPgC0A2LakQ8ZLQySwiRwTTtyo4Br4GE HEcIJl/990pvGaFRs2zaMCpAuM3FcXpDS9qL3kqKawT6qNLWtjfzWvcyIDvZ1f9p VpFpJa36Fk0ZMGYthHjQBbrYXn8JGESOmAUC95hs6H2TnJX55wR+G6PuSzCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1659905199; x=1659991599; bh=nYZa9aAjnCIk45IKTQIC9AaHNDyE aZIUkFk4aJ3Jyl8=; b=F6ntwlE1LvHHB3F7kG8ZXPf9pDHugd/Q0oYcTIh3FYko vS/WUlCTtPpugCMyw62wa1H+l7wDgyHBafRdT4dZ0EIBkFKroJW2VvnIhCr79MwT /8lcTZyMorGJhkvLb8U4Dfa2x72w//dTDOiYD69gD5u0vugOdJODK4FxQ2+oPJQ+ 85gPAkA61E2FK7c0DgLE7RWke/EuAKyYL0l7ZGK/pTtOhgurLQnKqXFYbn70FMRK bRSKBAKj6xrzGgXijh3D8C5PGMwRosSJ/eNp2U/EsKF165wH3bnIwl10LahAHUIW 2ckPMsqzOuxRi1wVSuwgLwqcDtPBQq5sXqkhOD13fw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdefiedgudehiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesrg dtreerreertdenucfhrhhomhepfdfqlhhlihgvucftvggrugdfuceophhhphesohhllhhi vgdrtghouggvsheqnecuggftrfgrthhtvghrnhepueetueffgfdtleffjefhhfefjeektd eifeefffeigeefhfegleffgeetheefteejnecuffhomhgrihhnpehphhhprdhnvghtnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhhphesoh hllhhivgdrtghouggvsh X-ME-Proxy: Feedback-ID: i835c46d5:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5279836A0071; Sun, 7 Aug 2022 16:46:39 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-758-ge0d20a54e1-fm-20220729.001-ge0d20a54 Mime-Version: 1.0 Message-ID: In-Reply-To: <578bd2ba-1594-fa0b-0f8b-3734af1f0383@gmail.com> References: <578bd2ba-1594-fa0b-0f8b-3734af1f0383@gmail.com> Date: Sun, 07 Aug 2022 21:46:19 +0100 To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Content-Type: multipart/alternative; boundary=f069ae1080e74cb2b93b6fbde53d3eb8 Subject: Re: [PHP-DEV] [RFC] Asymmetric visibility From: php@ollie.codes ("Ollie Read") --f069ae1080e74cb2b93b6fbde53d3eb8 Content-Type: text/plain On Sun, Aug 7, 2022, at 9:38 PM, Rowan Tommins wrote: > On 07/08/2022 11:54, Lynn wrote: > > Reading "public private", "public protected", or "protected private" > > reads really weird `public private(set) static self $property`. > > > Interesting, it seems that you've unconsciously broken it up as "public > private" followed by "(set)", rather than "public" followed by > "private(set)". Perhaps it's because of the position of the parentheses, > which do feel awkward to me at first glance. Would it read more > naturally to you with different punctuation? > > public (private set) static self $property; > > Or: > > (public; private set) static self $property; > > Or: > > public private-set static self $property; > > > > On 05/08/2022 19:08, Matthew Weier O'Phinney wrote: > > I'm wondering if this sort of behavior could be indicated via attributes > > instead? Something like `#[PropertySetBehavior(PROPERTY_SET_PRIVATE)]`. > > Attributes have the benefit of being separate from the property > > declaration, arguably more readable (one per line), and composable. > > > Attributes are no more intrinsically "separate" or "one per line" than > keywords; the following would be perfectly valid with the RFC's proposed > syntax: > > class Foo { > public private(set) > static int|string $id; > } > > And the following would be valid with an attribute like you suggest: > > class Foo { > #[PropertySetBehavior(PROPERTY_SET_PRIVATE)] public static > int|string $id; > } > > Even a shorter attribute name would have the extra punctuation, and the > restriction that it comes before the normal visibility keyword: > > class Foo { > #[PrivateSet] public static int|string $id; > } > > > Regards, > > -- > Rowan Tommins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > Just to throw in my ten cents: I'm not sure if this is because I was recently reading about the fact that PHP doesn't have proper support for a comma operator, but I quite like the idea of providing them as a comma-separated list. // Public for get and set public int $number // Public get, private set public, private int $number If a single visibility is provided, same old same old, but if two are provided, they are in the order of get, followed by set. While not being as verbose as providing (set) or other markings to differentiate them, it feels more natural, and it doesn't overcomplicate it. --- Best Regards, *Ollie Read* --f069ae1080e74cb2b93b6fbde53d3eb8--