Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126731 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 280FB1A00BC for ; Thu, 13 Mar 2025 12:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741870459; bh=n5IbNBQLqH3VS9FenDOLFwthvxz7aeYs0h8rMRrqtkM=; h=Date:From:To:In-Reply-To:References:Subject:From; b=Hh+A2qCbOVkiXRSSKc/TXqVogv8QzvlLwNIb6vh9V9a89QopG62CgqodqDOP4oanL FUEiBNUEUF6/5DPOU0NE5Se4Lu9Trht24UnDoFPV3SRSVeHAVmSOGvvJx9VmIe7RSF ULY/ENz2OJD7WEZ1eNPvNG3PZ9UQDtt1jO4f/yLNBvBqelL2TgvoLLctwNTkgHh/fs 3O+WUFuk823mEEINBbzvWkzJ4Iub0tuu26RyJPXZcOWT8d3djNRc12yU6c3IqBLnHT EqAafbJ8ZFIwDTb0pGqd+43uRqu5w5y2C7jaZUviPVd62OYgKVIm1/eECgr4m9xkG9 DUgYZqvSCfhnQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 411F1180050 for ; Thu, 13 Mar 2025 12:54:18 +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=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 ; Thu, 13 Mar 2025 12:54:18 +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 F3A2911401B4 for ; Thu, 13 Mar 2025 08:56:50 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-11.internal (MEProxy); Thu, 13 Mar 2025 08:56:51 -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=1741870610; x=1741957010; bh=n5IbNBQLqH 3VS9FenDOLFwthvxz7aeYs0h8rMRrqtkM=; b=rOSL6A9ilhoWjYAMI0dta0Ke4R uMsqMfxFJZbi+uj5tgR/yMj7ObdMNCGhmepCbJNqRQKnLLvQLQKsIrcPfRvxFgBR CZz6OLafL67nqjjyEcpK3HanB6Vd1W13w7/IXULeCvh28CgOQkOU+ZOhYR7sFYV4 aV8xpNi66otjjRwROpQZC8TFIppiXW+jrpE56nUPjJH1u8ROa6x7ZlleyRD+XDBw HpkKTxxbCapJv4bKZPMOR91rLR3woKRDX7qOdZqbSrYPnVEfC6VTT6PHWZQSE6Qk PNd07C/Gxddm9c7se9QySi88FthLXK+Yqvv/+SjmdsviImmTT1NzOmzvJCDg== 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= 1741870610; x=1741957010; bh=n5IbNBQLqH3VS9FenDOLFwthvxz7aeYs0h8 rMRrqtkM=; b=k16QPtQXKEzq9Hw0yvlQidKPKyO2XjhhQgOAxsbT3D5Bie0lqUV dSavC5yzBteJSohoocRfgwYCmXmoHUdvGoAiCSPISjbRMwSuawpYe4sVfN5KmBPl 0XeF2oCoZr8ZVoUENsYCU0cAr0MlzpxSPyrgId3OigGmkMlQ1/sxSr84AKgwo1Gi ToqBP2nAFErLDLQRYRrgtK1Z4G3EcL6daO3wH9EIl9LCDppx98Cc8vBvI4e1NHIs iJPCFN1UYi77qjIa4xJ88ZsQ4FHLx0bkcGN6RKyw+1Stda/fwD0jn5MNyMn2vg9G uSVNyTEAG/KQW8pdinnkVMOTMjJ49l4MxSA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduvdektddtucetufdoteggodetrf 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 815AF780068; Thu, 13 Mar 2025 08:56:50 -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: Thu, 13 Mar 2025 13:56:30 +0100 To: internals@lists.php.net Message-ID: In-Reply-To: References: <2935d0e2-ddc4-447c-ab37-c9b7337b8b60@app.fastmail.com> <0d94bf183543ee9948fcd31337198438@bastelstu.be> Subject: Re: [PHP-DEV] Re: RFC: short and inner classes Content-Type: multipart/alternative; boundary=bf75109edf8f41da8e14749da403b383 From: rob@bottled.codes ("Rob Landers") --bf75109edf8f41da8e14749da403b383 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, Mar 13, 2025, at 12:41, Ilija Tovilo wrote: > Hi Rob >=20 > On Thu, Mar 13, 2025 at 12:01=E2=80=AFPM Tim D=C3=BCsterhus wrote: > > > > Am 2025-03-12 11:10, schrieb Rob Landers: > > > - Accessing inner classes is done via a new token: ":>" instead of > > > "::". > > > > I don't particularly like that. It is =E2=80=9Cinvented syntax=E2=80= =9D and I don't > > think that inner classes are sufficiently valuable to dedicate an en= tire > > operator to them >=20 > I would like to echo these thoughts. I also think the RFC is kind of > missing the mark. Arguably the most common use-case for `@internal` is > to restrict a class to a specific package/module or namespace, > regardless of the user's class hierarchy. I believe you specifically > call this a non-goal: >=20 > > Currently, many libraries implement =E2=80=9Cinternal=E2=80=9D class= es by using a naming convention or an @internal annotation in the docblo= ck. Inner classes enable libraries to define an internal class that cann= ot be used outside the class it is defined inside. This feature is not m= eant to be used as a =E2=80=9Cmodule=E2=80=9D system, but rather as a wa= y to encapsulate logic internal to a class, such as DTOs or helper class= es. >=20 > At least if I understand this statement correctly. >=20 > In that case, I see much less value in nested classes. They might > still be ok if they are extremely simple, but the proposal is > currently quite complex. It has a custom operator, it deals with > shadowing, LSP, runtime resolution and more, in addition to visibility > which is the actual goal. Maybe more use-cases are enabled, but I > don't think they are currently well described. Assuming visibility can > partially be implemented in a simpler way (e.g. top-level, > file-private classes), the costs seem to outweigh the benefits in my > opinion. Hence I would not be in favor of the RFC in this or a similar > form. >=20 > Ilija >=20 Hey Ilija, > the proposal is > currently quite complex. Most of this is just describing how classes work already and going in-de= pth on where there may be confusion -- there are no significant changes = to how classes actually work. The actual changes to the engine are basic= ally just visibility rules, some syntax changes (to allow nesting `class= ` inside another class), and handling the new operator. The hard part is= explaining how classes work, because they don't really have a defined b= ehavior. In other words, I cannot just say "the way this works doesn't c= hange anything." > They might > still be ok if they are extremely simple And now you can understand why they WERE just simple classes (short clas= ses). So, you can see why I originally bundled them together because of = this EXACT argument. :sigh: > to restrict a class to a specific package/module or namespace, > regardless of the user's class hierarchy. I believe you specifically > call this a non-goal: I was specifically echoing this callout from Micha=C5=82 earlier in this= thread and other emails/comments I have gotten off-list; including my o= wn libraries. I usually have DTOs that I want to use specifically for ce= rtain things, but not expose them in the user application -- or even the= rest of the library. This isn't a replacement for "modules" or "namespa= ce privacy" but rather, complements it, if we ever implement it. =E2=80=94 Rob --bf75109edf8f41da8e14749da403b383 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Thu, Mar 13,= 2025, at 12:41, Ilija Tovilo wrote:
Hi Rob

On Thu, Ma= r 13, 2025 at 12:01=E2=80=AFPM Tim D=C3=BCsterhus <tim@bastelstu.be> wrote:
>
=
> Am 2025-03-12 11:10, schrieb Rob Landers:
= > > - Accessing inner classes is done via a new token: ":>" ins= tead of
> > "::".
>
&= gt; I don't particularly like that. It is =E2=80=9Cinvented syntax=E2=80= =9D and I don't
> think that inner classes are sufficie= ntly valuable to dedicate an entire
> operator to them<= br>

I would like to echo these thoughts. I also= think the RFC is kind of
missing the mark. Arguably the m= ost common use-case for `@internal` is
to restrict a class= to a specific package/module or namespace,
regardless of = the user's class hierarchy. I believe you specifically
cal= l this a non-goal:

> Currently, many lib= raries implement =E2=80=9Cinternal=E2=80=9D classes by using a naming co= nvention or an @internal annotation in the docblock. Inner classes enabl= e libraries to define an internal class that cannot be used outside the = class it is defined inside. This feature is not meant to be used as a =E2= =80=9Cmodule=E2=80=9D system, but rather as a way to encapsulate logic i= nternal to a class, such as DTOs or helper classes.

At least if I understand this statement correctly.

In that case, I see much less value in nested classes. = They might
still be ok if they are extremely simple, but t= he proposal is
currently quite complex. It has a custom op= erator, it deals with
shadowing, LSP, runtime resolution a= nd more, in addition to visibility
which is the actual goa= l. Maybe more use-cases are enabled, but I
don't think the= y are currently well described. Assuming visibility can
pa= rtially be implemented in a simpler way (e.g. top-level,
f= ile-private classes), the costs seem to outweigh the benefits in my
<= /div>
opinion. Hence I would not be in favor of the RFC in this or a= similar
form.

Ilija


Hey Ilija,

the= proposal is
currently quite complex.

Most of this is just describing how classes work a= lready and going in-depth on where there may be confusion -- there are n= o significant changes to how classes actually work. The actual changes t= o the engine are basically just visibility rules, some syntax changes (t= o allow nesting `class` inside another class), and handling the new oper= ator. The hard part is explaining how classes work, because they don't r= eally have a defined behavior. In other words, I cannot just say "the wa= y this works doesn't change anything."

They might
stil= l be ok if they are extremely simple

And now you can understand why they WERE just simple classes (sho= rt classes). So, you can see why I originally bundled them together beca= use of this EXACT argument. :sigh:

to restrict a class to a specific= package/module or namespace,
regardless of the user's cla= ss hierarchy. I believe you specifically
call this a non-g= oal:

I was specifically echoin= g this callout from Micha=C5=82 earlier in this thread and other emails/= comments I have gotten off-list; including my own libraries. I usually h= ave DTOs that I want to use specifically for certain things, but not exp= ose them in the user application -- or even the rest of the library. Thi= s isn't a replacement for "modules" or "namespace privacy" but rather, c= omplements it, if we ever implement it.

=E2=80=94 Rob
--bf75109edf8f41da8e14749da403b383--