Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126758 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 803F31A00BC for ; Fri, 14 Mar 2025 17:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741973732; bh=mqouqSg6yZKcQdrEaZIzzP4+8okEe+a5SF38RR7kS/w=; h=Date:From:To:In-Reply-To:References:Subject:From; b=cK4OXZa4mBCbakc3+JX+4qMwwc0ttIirB2q4yQAkMnyaEy9/RN+hjd894R6M3r0uv oypPHpbEE452wIAq15fnwSodBImvCrBODA6FjeLdr55m/2Zg6GZ9z6cRHWvOzkx7/l rE6W2MBIXqfBfE+UzvhrBicZwgruUmE3VqyV4FXlxNezL5BFrcMjoLIIS+wMcVlE8d Ronj0SWe7Zj/ha+msY6l2ne67EmF5XqJQGLVdocJCJxE27v73og44q/AI7SpZODyes QW4ANSLlYiHB1wQVnx6KthyXkC3WwYOctiJvSYHZHUEmOdeaQhTmJL0W/8AmfnDcV2 INzoNV9nCK0hA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 42CA218003C for ; Fri, 14 Mar 2025 17:35:31 +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,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 ; Fri, 14 Mar 2025 17:35:31 +0000 (UTC) Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.stl.internal (Postfix) with ESMTP id 7A37E1140180 for ; Fri, 14 Mar 2025 13:38:03 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-11.internal (MEProxy); Fri, 14 Mar 2025 13:38:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=1741973883; x=1742060283; bh=QvKz+x+jkc Xo7kKsfr+Cudknlo162ps+6Sj0XduQctI=; b=RfWEDzEu0wS/UR6HR52NYZ3UxX 89EiF1l1Yl5jBknXUk8Lur7BWtzL7BAb75lS8TkIc5c+WBtq2JakcB/FabaNbixU XUftne0NYjWf/OpZLomoimjO7xyI13NWZJ03Bfv/IOpLrKxXtdr/s6Mk5Y7j1OW3 2lab6XRCg7KcmZXHoFEO2Kzn4AliYaV1toNfGoDC+jlzrc2QwdmwW0Xuj/V6LDZk SKuYnhJImEjnrhRzUqxF/8xNv2vVx7qIlvZP97130iAwQ2e4I6o3ceGuiNhUIiK8 O3P010gdYs5en+OPP3ZBqphL92FS6oSyCVe80PrpToWvi4EP2zl48IVFLWOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm1; t= 1741973883; x=1742060283; bh=QvKz+x+jkcXo7kKsfr+Cudknlo162ps+6Sj 0XduQctI=; b=cJuLhta5UU6dBSAlFbdx0+x3Keo5XGk5KV6IoAi0iHIdB9++8HA uzcPQvNFzjm7Dfh1erFU9DTQLFgj3z05ZrmqDzLudPjzQXF6v4pkhemzU1SbBGPy /GpmaI7O1PYdgx2f3dBxWmePA6/msyTzTo+cBP9QpnGLLjFeAi/Yy3cbx9/uNcDx ZFlpXYRNp+uC6whHhdGyXyx44r/5H2r9lBfgUJXXSAQLXtxy3kiLf9aSCHVBlujt PrCFhEcMUcmPFKx8r9uuuX4QhbkXeYo3non39OQZCNHSf5rxV0vtH3xikrGb6t3p /D521FWg/ownqSF0aFIj1XPho1/cAuzXVDg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddufedugeehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefogg ffhffvkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhs fdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpedtue ejtdethfeulefhtdelieduteelffdtudelheffgedtieehhfelieejgfevgeenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtth hlvggurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id EF1F2780068; Fri, 14 Mar 2025 13:38:02 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 14 Mar 2025 18:37:27 +0100 To: internals@lists.php.net Message-ID: In-Reply-To: References: Subject: Re: [PHP-DEV] RFC: short and inner classes Content-Type: multipart/alternative; boundary=6be66dd0d96247f4be3fae63cd776e45 From: rob@bottled.codes ("Rob Landers") --6be66dd0d96247f4be3fae63cd776e45 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Mar 14, 2025, at 17:09, Ilija Tovilo wrote: > Hi Bob >=20 > On Thu, Mar 13, 2025 at 11:36=E2=80=AFPM Bob Weinand wrote: > > > > On 6.3.2025 23:20:37, Ilija Tovilo wrote: > > > > > I would also like to echo what has been said about the :: operator, > > > which feels out of place. I understand that \ comes with additional > > > autoloading challenges, namely requiring a fallback autoloading > > > strategy that currently does not conform to PSR-4. > > > > Could you please elaborate on why the :: operator feels out of place? > > > > \ is a namespace separator. > > > > :: is a class scoping separator. > > > > > > You, yourself did decide to use nested :: for property hook scoping,= like parent::$x::set() - a property scoped within a class, having metho= ds. > > The same applies here - it's a class scoped within a class, having m= ethods. > > > > Breaking from these patterns seems very surprising to me. >=20 > :: is an operation performed on the class. E.g. fetch a static > property, fetch a constant, call a static method, while \ is part of > the class name. The way I see it, the outer class can simply add an > additional namespace component to the inner class. >=20 > class Foo { > class Bar {} // Called Foo\Bar >=20 > public Bar $bar; > } >=20 > This is dead simple, it doesn't change any assumptions about class > names by embedding new symbols, it doesn't need a new operator, you > can refer to the class with its short name from inside the outer class > without `self:>`, which is shorter and more straight forward, `use > Foo\Bar;` will just work in other classes, etc. >=20 > One thing this approach breaks is that it doesn't allow for > polymorphic inner class resolution, i.e. static:>Bar. But given this > was removed anyway, that point no longer applies. This can also easily > be replicated by a simple method: >=20 > class Foo { > class Bar {} >=20 > public function createBar(): Bar { > return new Bar(); > } > } >=20 > Except this is actually type-safe, because the return value of > createBar() must stay compatible with Foo\Bar. >=20 > Ilija >=20 Hi Ilija, What about a hybrid approach? Maybe something like `\\` that Tim suggest= ed? But hear me out. Instead of it being between all inner parts, it is = only between the outermost and inner parts of the class, otherwise just = use `\`. This also solves a problem where: - we don't need to change anything with autoloading - we can differentiate between different types with the same name So namespace Foo; class Outer { class Middle { class Inner {} } } namespace Foo\Outer; class Middle { } can be differentiated from each other (Foo\Outer\Middle vs. Foo\Outer\\M= iddle\Inner). I also like the idea of just using the name instead of having Foo:>Bar..= . I think that is possible now that I have all the machinery in place fo= r visibility. I may have the implementation ready today/tomorrow (as per= the currently written RFC). =F0=9F=A4=9E =E2=80=94 Rob --6be66dd0d96247f4be3fae63cd776e45 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable