Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126927 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 D49ED1A00BC for ; Mon, 24 Mar 2025 19:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742843986; bh=TQmElofI53iJGsISSBvhBGKy14sAdYsw9Wow5Kdq3No=; h=Date:From:To:Subject:In-Reply-To:References:From; b=G47kM6vaFlR/nz9f0pKZYtNqyc1AXwJtqWsMxSJsxWTfEInkvAkl+adbndB8goBBu SYkfX7vCXEOcAOVUegZorJAPSfA4hXde5U5jw5tXwjI1hTTBKM3AHk8Yi23vrBDC/u 2bD4YEMSa1XYU9iXMuf3pJsIWSn6wPWRt8pImWW64yEF8tgzx/fZbQyTeycdg+paaG MPyM0EmaswwETGKPQhPdgNM8/smVy5+TxDdY2v9C+qv1hnX5jE28yXfNxctuxPv3j6 bsUlZBM+4x6E9SahWsakre5btyyw0Hjd6R/FaQmufG51KfJ9qUuogDxikLXW+hggzm 4j2nTX/avkNVQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 322731801D4 for ; Mon, 24 Mar 2025 19:19:45 +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_H4,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 fout-a5-smtp.messagingengine.com (fout-a5-smtp.messagingengine.com [103.168.172.148]) (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 ; Mon, 24 Mar 2025 19:19:44 +0000 (UTC) Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id E59351383BE4 for ; Mon, 24 Mar 2025 15:22:13 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Mon, 24 Mar 2025 15:22:13 -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=1742844133; x=1742930533; bh=eZ5n+C+OZDMshgXtksYII7VBFOR8DB9poKURCLXyQis=; b= ojLYokWHwebhb5BC/ymsHwOCT8e93g9BAetmv1LQ1tnFehW97c3XAdXYEzVJkzvD SZkJdRiNRwFhMq0EYedhU6DJFXM4oGNb3h2ecktAdrWhARZYTCBbZGfucf7JKwc5 +VoSglmH6u+YF71mIrMY4wIiP/t+CHYlls+0vJK9jscVxflYtZAcV5XwLgTHAQNA L1iCFsZ7bd3OjTI3hhDG/xnawmcKsqVzyxEHLXh5T3Dy2DCcjHdLAlJp4R2lguss RxR57h7RQfBV55sA/cQyPmyfDLa6syGlC8is2mdFT1Somz0+6+I1Z7l1D2g045/9 0TgnSIBWahEWkUJx51rI8A== 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=1742844133; x=1742930533; bh=e Z5n+C+OZDMshgXtksYII7VBFOR8DB9poKURCLXyQis=; b=YFsw5qQu1goEEe37W 3tZpzE+ucnQYrDP1O/b06+1v6qGaIyoDzZzSrmxl9q32eJ1BvDrzNki9fKheIz70 2A/wL0aNb9ssDRHkMxZhk14e8K6W9IRbma6BRsG7/tvPpois84QVkt2SO6G584l8 OLM1HrXMlZLMq9p+WT2EoIf3wYNR7MGVcie0R4wjGL52YLxeZzSw7sbbIyMWJzFP /UykrDGulsYCK7gyY+9YMbRPpkX+wKhOp1cMr1He3JxH6Il1kGEDu4IHjPKG8IHw HfeF8krIx+EItAEf4xGnAwiajE+0R+M9F+g85dGktJvX9Qg33ApWSsgWzODM7Gol znsQQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduiedtiedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhf fvufgfjghfkfggtgfgsehtqhhmtddtreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhm ihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeehleffteeigfevudetfedugedtudevledugeeugeelheei hfehgfdtkeevvefgleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 24 Mar 2025 15:22:13 -0400 (EDT) Date: Mon, 24 Mar 2025 19:22:12 +0000 To: internals@lists.php.net Subject: Re: [PHP-DEV] Re: RFC: short and inner classes User-Agent: K-9 Mail for Android In-Reply-To: References: <2935d0e2-ddc4-447c-ab37-c9b7337b8b60@app.fastmail.com> <0db0cce1-c2da-4298-a7a0-c9c9c82ab498@app.fastmail.com> Message-ID: <15A2D8E5-6D28-4B77-AA6D-6944F237B606@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 24 March 2025 09:20:03 GMT, "Alexandru P=C4=83tr=C4=83nescu" wrote: >On Sun, Mar 23, 2025 at 5:20=E2=80=AFPM Larry Garfield >wrote: > >> >> So, how would nested classes compare to fileprivate, in terms of abilit= y >> to solve the problem space? As I understand it, the goal is: >> >> 1=2E Classes that can be instantiated only by the class that uses them= =2E >> 2=2E But can be returned from that class to a caller and reused as >> appropriate=2E >> > > >I think the one other difference is that nested classes can access privat= e >variables or their outer classes=2E You can achieve the same with "file private" access: in your example mark = the constructor as "file private", and put the Builder in the same file fileprivate function __construct(private array $points) {} If you'll excuse a brief philosophical detour, I noticed something interes= ting in the Swift documentation: the description of nested classes doesn't = describe any special scope access=2E Instead, the description of "access le= vels" defines "private" in a way that naturally includes them: > Private access restricts the use of an entity to the enclosing declarati= on, and to extensions of that declaration that are in the same file=2E It's a subtly different framing - nested types aren't breaking into the pr= ivate entity, the "private" keyword is explicitly letting nested types in= =2E A language could, if it chose, have different keywords for "private to exa= ctly this type" and "private to this type and any nested types": strict_private function __construct(private array $points) {} private_or_nested function __construct(private array $points) {} Just as there are many combinations like "this class, subclasses, or other= classes in this module"=2E The point being that there's nothing fundamental about nested types that g= ives them access to private properties=2E What they do is give us a new dim= ension to define access levels of our choice - { contains, contained by, ne= ither }=2E File scope gives us instead the dimension { same file, different file }; a= nd module scope gives us { same module, different module, no module }, and = maybe some additional relationships between modules=2E Rowan Tommins [IMSoP]