Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125465 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 8AECC1A00BD for ; Sat, 7 Sep 2024 08:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1725698261; bh=sglMem/SgEdbvuZ7Od2PcZZWtyuzxlbe0cvbv56qVXE=; h=Date:From:To:In-Reply-To:References:Subject:From; b=EKl4rmqvXCH+/5zEd+It/UlsYo8cltPjAAXPJHVBzqhEIH7Ib2hAoLnKDq3PcKtAW lfWxVPiicl8MCZ9Cbq8fcaoH0rTVQBR7NJdFFCXeNBlAMgvjIt+lQo2fFTam5xdGfU XV2wlEtsOv9/srVZnYUHY1GzrF4nkVCMkXw/soIx2gej8mnwa2yxKQw8+rRg7I3ezd QatPDsbPo67k4+iHyMnrLCrs8pwLRxsUWM6A3zwRAUpgarQKQpd40IQ3zGvXl+8PT1 i9vQOTOrphh/tSNofBAoaGJu0Bdgw1LFCR7gr/5fASSoYWMwH3y56edRQads4YjmfA 8YzgnOuxxkhOA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 983D5180052 for ; Sat, 7 Sep 2024 08:37:40 +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=-0.9 required=5.0 tests=BAYES_40,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 fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (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, 7 Sep 2024 08:37:39 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 33FCD1140339 for ; Sat, 7 Sep 2024 04:35:40 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Sat, 07 Sep 2024 04:35:40 -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=1725698140; x=1725784540; bh=hH0+a8DRFW rltCrgbTR6EY0pk/3tzHNYK6pENRJLLQM=; b=dPX2eX8TMnC1P9rVuV8nih3bZ2 kJUPA6y2DmKQ8C2MPPNAGXOr5uc/2NkjxkWs46YjYf32jXMvRXOuoIb/d/YmItiT 0nH2Dbs5s+25YCFmegUC9i0lNaRAQJ/EBm9hZx5oglpJeL/1ACBbc98KwQGCFXzv 7TIhnqa9uBUaWjWqKL7DxexNJK8T1sXmwdL1BCpHRO3lcx9xqJoMs0TDUUhEpk0+ Fkf4/QMXmThJaytJrKkWkbp3HFbLcEu+KnkBnFWd3+b8kXyY+CvUfCvHpdzAYi/4 kb9TGbkkrjJOd0j7O4laUWzR7sy/YpNTii92XS4i8a9+z41ogmMKtUiBQW5g== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1725698140; x=1725784540; bh=hH0+a8DRFWrltCrgbTR6EY0pk/3t zHNYK6pENRJLLQM=; b=XIyR/RJtKeZPe7t44Rw7ZcmoAHScIFdTQ+OKRlAiqd6x Q1gfRBPqtTTQFWaQ0tImkOsDGMT48fWmlQPvn3aYwSfU8g9qEPKCC+iDySmog9rP f6jYV7CarU98i8XMiwpxJoZwwEC4QotsIev9ganzHHPSYLKgCBZCpUI2kx1ovlBY pcPZNZnqgEa03vs0YmSR3w6+AFl6n4u7kQcU/rjDhmeK3srCFiffxB7J79oia0Kr K9/UlhfIyCYx3uxoF0KfFMCPtBB7B9Tl8NZQyDOTdsmhSv/Hc/pbt/Mtsdq7FWdF +Zh80I9Q2LsDRHUlljzcCBwlvYYXqabMfShKWnp37Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefoggffhf fvkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcu oehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpedtueejtd ethfeulefhtdelieduteelffdtudelheffgedtieehhfelieejgfevgeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvg gurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgt phhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C9752780068; Sat, 7 Sep 2024 04:35:39 -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: Sat, 07 Sep 2024 10:35:19 +0200 To: internals@lists.php.net Message-ID: In-Reply-To: <66DBC5CA.3050901@adviesenzo.nl> References: <0fa39535-f22d-4eba-b4df-90abe39e683a@app.fastmail.com> <66DBC5CA.3050901@adviesenzo.nl> Subject: Re: [PHP-DEV] bikeshed: Typed Aliases Content-Type: multipart/alternative; boundary=9ebe15dc4d114fc586ec11c1a4fe3029 From: rob@bottled.codes ("Rob Landers") --9ebe15dc4d114fc586ec11c1a4fe3029 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Sep 7, 2024, at 05:17, Juliette Reinders Folmer wrote: > On 6-9-2024 20:41, Rob Landers wrote: >> - This RFC expands the "use ... as ..." syntax to allow any type expr= ession on the left side. These aliases are PER FILE and expire once the = file is compiled. >>=20 >=20 > Explicitly without expressing any opinion about the RFC, I'd just like= to remind you that `use...` import statements for classes and such are = not actually per file, but per namespace and making the `use ...` statem= ents for types behave differently would be very inconsistent and surpris= ing behaviour. >=20 > These are the rules (as far as I know and based on extensive testing f= rom my side): > * No namespace - `use` imports apply to whole file. > * Curly brace scoped namespace - `use` imports apply only to the code = within the current namespace scope. > * Single unscoped namespace - `use` imports apply to whole file (as th= e whole file is within the single unscope namespace) > * Multiple unscoped namespaces - `use` imports apply only until the ne= xt namespace declaration is encountered. >=20 > Having type `use` behave differently to other import `use` statements = would, I imagine, also bring up problems around "file contains 2 scoped = namespaces, type use is for the file, but - as things currently are - no= code is allowed in the file outside the scoped namespaces, so where to = place the import for the type ? and what would it then apply to ?" >=20 > Smile, > Juliette Thanks Juliette, I meant "as they are now" and not literally "per file" as described in t= he RFC. I will make that more clear in the RFC. When I wrote it, I was t= hinking in terms of how I usually write namespaced code and thought of i= t as "per file" but that is probably the wrong mental model in any case.= Thanks again for pointing this out. =E2=80=94 Rob --9ebe15dc4d114fc586ec11c1a4fe3029 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Sat, Sep = 7, 2024, at 05:17, Juliette Reinders Folmer wrote:
On = 6-9-2024 20:41, Rob Landers wrote:
- = This RFC expands the "use ... as ..." syntax to allow any=0A type= expression on the left side. These aliases are PER FILE and=0A e= xpire once the file is compiled.


Explicitly without expressing any opinion about the RF= C, I'd just=0A like to remind you that `use...` import statements for= classes and=0A such are not actually per file, but per namespace and= making the=0A `use ...` statements for types behave differently woul= d be very=0A inconsistent and surprising behaviour.
These are the rules (as far as I know and based on extensi= ve testing=0A from my side):
* No namespace - `use` im= ports apply to whole file.
* Curly brace scoped namespace= - `use` imports apply only to the=0A code within the current namespa= ce scope.
* Single unscoped namespace - `use` imports app= ly to whole file (as=0A the whole file is within the single unscope n= amespace)
* Multiple unscoped namespaces - `use` imports = apply only until the=0A next namespace declaration is encountered.

Having type `use` behave differently to oth= er import `use`=0A statements would, I imagine, also bring up problem= s around "file=0A contains 2 scoped namespaces, type use is for the f= ile, but - as=0A things currently are - no code is allowed in the fil= e outside the=0A scoped namespaces, so where to place the import for = the type ? and=0A what would it then apply to ?"

<= /div>
Smile,
Juliette
Thanks Juliette,

I meant "as th= ey are now" and not literally "per file" as described in the RFC. I will= make that more clear in the RFC. When I wrote it, I was thinking in ter= ms of how I usually write namespaced code and thought of it as "per file= " but that is probably the wrong mental model in any case. Thanks again = for pointing this out.

=E2=80= =94 Rob
--9ebe15dc4d114fc586ec11c1a4fe3029--