Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126944 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 100351A00BC for ; Tue, 25 Mar 2025 22:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742941069; bh=w2ULuG6w6oq5smvprpXFoVECU/zIcTqtuzCUMYd/Z0s=; h=Date:From:To:Subject:In-Reply-To:References:From; b=e6cAoagSHq3aP5XZGF3AmAwFpqZ0vqbQWajUg0STnvl9ShxZtg9a2jzHoUxvKbYEe ahw5mj9azg9BoUGQYKR7Jik48AsepP+R+tg0bkjhhoypKrabgiFQzHdNJvo90DqL6y 7q44U1tSYuDi6FRbeXgLmwnt/BhLRuHzOa6tSlJJeGpaq2wlopm1mRTNjHnCJj9iJS GsWlHAnSTQ7E4ePk51QIWJiUq09Sl45Fl3BMHuKkziIf3Ymf9NGvqETLNGraKnw6lB piUc/XZhCZnIhPTFHWr1LUB08Drk6sxAUw2jnN4pMHZa8GqW38dl1Rx6Q2b5WxA/XH qhZGIfiSZgOZw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A705E1801D6 for ; Tue, 25 Mar 2025 22:17:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-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,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 Mar 2025 22:17:48 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id B814D2540169 for ; Tue, 25 Mar 2025 18:20:16 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Tue, 25 Mar 2025 18:20:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1742941216; x=1743027616; bh=w2ULuG6w6oq5smvprpXFoVECU/zIcTqtuzCUMYd/Z0s=; b= gX7rWGxDAq4WO1g5oWyqdec4zfdyulICedWsipkdCYFm5b6yqlWEX8LQ2fXgdz6Y a9IYdMexTWGT7O+H5g/G7imvVjqxMxYYA9bb5DtdMoz6hlWBBaTDFkRyqMjXK7bQ iog0kACoV27xGdaWZ79jUIKv9mH5j4VHRncTrdTI1R6jzKM1b5U1Rn0QslmTZ+jB J7ZnSmVoN3+KI4UHA7nLU2lwHigV6+rtdhPnVHQk0OFGUabmqIkRvfBTtk6ti3MJ OAh8h4Nl3cNRpgQ+B1ZdFh+5HTQG3wntYPLbf2Vhoa1+tmf+tRpDV5w96omeojIW B2FvHkIVasuJJaqOQBbIow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1742941216; x=1743027616; bh=w 2ULuG6w6oq5smvprpXFoVECU/zIcTqtuzCUMYd/Z0s=; b=QtRQI+45aUn7n5w7A NJ/U7y6M7gy4f/3zFHpORavwQ/3zK2lXppRZRL45OTZ7nV2Hc+3TDyvGaaUtFRsz nt8Icli122YDOfJHlQ44qY9pWoSt2fxZnXncrEB6xtc0MenbnFYI1ZKrpMH8jnKg hwuNnuTITBbTYmgWs1G/7T2NRavcvCgrTTmt3UBNQCg8gMwj4A9N+XgGwym1d5OI MVZveF3AcxBpyOTXIMaODZRmFDd0slEesQga2Cnrf64JeyP86MKbbQ2mdYz0uz0L TEoGNqwO+16eeRLwXak5kGTn4R9sRIuZyYcZuZusNOP3jc+rMJSzxSMkk1bfPcbn T6iGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieefkeefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucgoufhushhpvggtth ffohhmrghinhculdegledmnecujfgurhepfffhvffufggjfhfkgggtgfesthhqmhdttder jeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehimh hsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnhepueevleff ieefgefhhfeujeduteeigeetteegffegledvhffhleevvdeijedugeeunecuffhomhgrih hnpeefvheglhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpth htohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlshes lhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 25 Mar 2025 18:20:15 -0400 (EDT) Date: Tue, 25 Mar 2025 22:20:13 +0000 To: internals@lists.php.net Subject: Re: [PHP-DEV] RFC: short and inner classes User-Agent: K-9 Mail for Android In-Reply-To: References: <48dce917-d147-456b-9f03-c7e23411adff@app.fastmail.com> <8a16b81c-7dab-4523-a352-76ba0cb4e771@app.fastmail.com> <9c4ac301-dfb2-49da-90e5-37a2824fc4e3@app.fastmail.com> <5b1e6d70-a1c9-455c-93d3-6b22cf1fef11@app.fastmail.com> <52d84a5b-09d3-4e42-9620-a62fb239c21e@app.fastmail.com> <09a82882-f1ee-4bdb-8a27-e46144a711f1@app.fastmail.com> Message-ID: <2512DF25-6B2F-4C18-8F49-17F2665ADB53@rwec.co.uk> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 25 March 2025 21:23:48 GMT, Rob Landers wrote: > >> If we didn't have "protected", would you ask the same about "protected = private"? "fileprivate" would be just another access level, not something y= ou'd combine with existing ones=2E > >Actually, probably yes :) Mostly just to ask for clarification=2E In this= case though, we have private(set) and protected(set); would we also want f= ileprivate(set)? That's what I was getting at=2E How do we mix/match up all= these things? I don't see what needs deciding - private(set) isn't a new access level, i= t's basically sugar for a setter that's marked private=2E Try replacing "private" with "level1", and "protected" with "level2": level1(set) level2(get) int $foo; And then add "level1a"; can you use it in the same places? Of course:=20 level1a(set) level2(get) int $foo; So why would there be any ambiguity about writing this? fileprivate(set) protected(get) int $foo; >> > maybe `fileprivate` on a property means `public` in the file, but `pr= ivate` outside the file=2E But then how would that intersect with inheritan= ce? Just to call back to this: it's like saying "protected means public inside= the class and its descendants, but private everywhere else"=2E It's an unn= ecessarily confusing way of describing it, because you then have to define = "public" and "private" without the definitions being recursive=2E A more straightforward description is "protected means accessible inside t= he class and its descendants, and nowhere else"=2E Maybe having "private" in the name is putting you off, and this is clearer= : samefile(set) samemodule(get) int $foo; No "private" or "public" involved anywhere, just descriptions of where the= property can be accessed=2E >> I see no reason for inheritance to be involved at all=2E If we want an = access level that means "accessible from any code in this file, or any subc= lass of the current type", we can make up a keyword for that as well - "fil= eprotected", or "fileprivate_or_protected", or whatever=2E > >Inheritance gets involved in traits=2E Traits do "inherit" private access= properties (currently): https://3v4l=2Eorg/89I7A Traits don't inherit anything, and they don't restrict anything either=2E = They paste code in, and once pasted it acts like it was written in the new = location=2E You can even change access levels while pasting, with the synta= x "use Foo { bar as public }"=2E The "private" keyword in your example is pasted into class Foo, and means = "accessible within class Foo"=2E It never applies any restriction relative = to trait Bar, because running code never belongs to the trait=2E A "fileprivate"/"samefile" keyword would be pasted into the file it was us= ed in, and mean accessible within that file; it wouldn't matter what file t= he trait was defined in=2E It would probably be useless, but lots of useles= s code is possible in any language=2E Besides, all these questions have to be answered for nested classes as wel= l=2E Just because you've reused the keyword "private" rather than adding "p= rivate_or_nested", you still have to define exactly what it does and doesn'= t allow access from in these new scopes=2E Rowan Tommins [IMSoP]