Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126779 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 3F9821A00BC for ; Sat, 15 Mar 2025 11:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742039445; bh=iar0ZfhnrTBItp4Lt1NLZgzkwCzlLMXqoH3aWjXV/JY=; h=Date:From:To:Subject:In-Reply-To:References:From; b=gVdKoQO2TFOCw9y7xruYuTjDmjqnUz7EqetlV6kyoKBB+7UdHjczkwD+Nj7Sg9osb Z7DhQby73u7bTP8EkFEzgSa9hn2O7RfbslE45HtGPvm9tPgW7HRS0BbpWGXmYOZkms uiP1s1e9n1w9uqbtYm+Mdbrt5/PXL5/C2SupNOUZ+vKd6ekgAyp1qPO+TpO4CibM1K omrdKyYsi4VNFaawsNE5zCmGEKeC2U6mFcSSaqeOUjOfmr3pnFQDjCYHf0rsNMnOl4 ktSdEcDtgvrrQt2JM/PlEKrBI+RFxXpxJz3tCfkZiRo8kM29P49lig+TZbbFQ0e5xx nXhDys+1D9ZSw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3E088180079 for ; Sat, 15 Mar 2025 11:50:44 +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, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (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 ; Sat, 15 Mar 2025 11:50:43 +0000 (UTC) Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1EB4F2540146 for ; Sat, 15 Mar 2025 07:53:16 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Sat, 15 Mar 2025 07:53: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=fm1; t=1742039595; x=1742125995; bh=iar0ZfhnrTBItp4Lt1NLZgzkwCzlLMXqoH3aWjXV/JY=; b= MjY/iwxLmiziMMR1VOitJC8pxtUlQwGy1EbyO0jAJRBGgJp5MKZ1vibZ28RBTy8b AV5qIlTS2VU5gw3USrDev/hj7Udwx/aJyrn6BeKcIew8z+A1jnJME8P+YOR4qMyl FuVZNNpadPJEWk1ZahbxvQTOOKHnfBYom43mMjR7MnyoO9bv+t5R7ZewZCX3dQxB vC6j5hLjgkPoipfOYPHpHUrMiESQ8nTNIW5amR26lnmzIusdteqhUrv69KbkRSqK RBUUaSS9AeyjWTlBRnnZD6EF1GsILReR0YTyg66brHJkSp4QR2u4WAT5qBxWXMMG 6ZNrbuS+20w5qboQUOMI4w== 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=fm1; t=1742039595; x=1742125995; bh=i ar0ZfhnrTBItp4Lt1NLZgzkwCzlLMXqoH3aWjXV/JY=; b=1WWhOOb4RcSN9RI1s w7GEuKj5bT2WAnUhB8szW/AIAo021ZtqZvOMv1ZnxZ8UfYBAn+CjvY2dOYhTJ0xY MgwpMFjArCnAVsFObiNBHJ2LndmmeAPJArcsZXy9SXr/SBOGAcyCFQUSYM2VFmvx +qtDPL9y9fz9ME0CS7kqR45fOnX8lQIOaaRxkEbYMrRwqRGbvvvzstBlY5C62wdd tqvrO4nk7eSVkUnk6YZHfd+Oekjz83Izy74JzVs+mG/p3i1e1Mj6S/bpjLC/K2st uQBKIZM+s3HHpDCMOMtTo71qVvHIiJS+yCOjIuBlzUpHqfZ7aE7KsUwKK0i4iDNS fCwPg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddufeefieehucetufdoteggodetrf 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 ; Sat, 15 Mar 2025 07:53:15 -0400 (EDT) Date: Sat, 15 Mar 2025 11:53: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: <4abd7008-ae33-46fe-8bbd-7c99f7c48158@app.fastmail.com> References: <4abd7008-ae33-46fe-8bbd-7c99f7c48158@app.fastmail.com> Message-ID: <0F1E4400-5E26-4E39-88B9-ABD7ABBAEBC4@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 14 March 2025 23:37:08 GMT, Rob Landers wrote: >I could get behind `::`, but I feel that it introduces human ambiguity=2E= I don't believe it would introduce compiler ambiguity, but as a human, I h= ave to hope the programmers are using a style that makes it obvious what ar= e inner classes and what are constants/methods=2E As far as I can see, all four languages I looked up last night (Java, C#, = Swift, Kotlin) use the same syntax for accessing a nested type as for acces= sing a property or method, so we'd be following the crowd to use "::" That said, I think they all also use that same syntax for namespace (or eq= uivalent) lookups, so the same argument can be made for "\"=2E (Why PHP sep= arates those isn't entirely clear to me=2E) Having some new syntax makes them feel more "exotic" to me=2E The C# and S= wift docs give the impression that nesting types is "just something that ca= n happen", rather than a whole new language concept to learn=2E Java's "inner classes" are something different, and I think we should avoi= d using that term=2E > Furthermore, I'm relatively certain this approach can be slightly modifi= ed to support "namespace private/protected" classes, in general=2E So, that= will also possibly be a follow-up RFC and having them mixed up will compli= cate things=2E In any case, I am not a fan of using the namespace separator= here=2E To me namespace, module, or file visibility seem like much more natural ad= ditions to the language, and to solve most of the same problems as nesting = types=2E I guess a public nested class is a bit like a "friend class"? In that it h= as special access to its surrounding class, but otherwise might as well jus= t be sharing a namespace with it=2E But it's also necessarily in the same f= ile, so marking those members "file private" rather than "private" would al= so allow that=2E A private nested class can only be explicitly mentioned within that narrow= context, which again feels very much equivalent to "file private"=2E > $user =3D new User:>Builder("Rob")->withEmail("rob@bottled=2Ecodes")->bu= ild(); > > The user builder is intrinsically tied to the User class itself, it isn'= t just a namespace=2E The user builder shares scope with the user class and= is able to be the only way to construct a user (barring reflection)=2E If we had either file or namespace visibility, exactly the same thing coul= d be achieved with those, and would look like this:=20 $user =3D new User\Builder("Rob")->withEmail("rob@bottled=2Ecodes")->build= (); The "User" class would have a "file private" or "namespace private" constr= uctor, callable from the "User\Builder" class but not elsewhere; the build(= ) method would return the "User" instance=2E I think I'm coming to the conclusion that we should use backslash: nested = types can be viewed as a shorthand way of having a class and namespace with= the same name, plus applying some visibility rules to that namespace=2E Rowan Tommins [IMSoP]