Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125098 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 B88D71A00BD for ; Thu, 22 Aug 2024 21:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724362448; bh=XVNOOg2M4je1c4JLqNOzdpPl3v3FUyhdF4/bVjlKCsw=; h=Date:Subject:To:References:From:In-Reply-To:From; b=fSy3OW9laK7QB5kpLU94dP19KGNF8CvHSxbUlzjFD0iiDxxc2G2hiHtlzslnYtL2y pulQEXAsHTOp5ADIUSkXAaIKOJ5CItCUoFR0fmSVM86biRPuWFcG7fDd6knPMVh79W ta0CNMUtgDdhN/3k/Vl9Syd7PYPdOEkCU2ERGM4YlWHLevYsTQagmVA/Y65WHbyWR9 mWfL3+yPjyJm+jIJCLGWmlRu7Jgo2+q11irYe/md1T5Lz1i7EaVOdcuRMwmxU3CEMu t4DvT7iwdn5ZZwMtL22o8p2evKKdjU9+3kBIktDG1gJmQ+CKxTn9aPBK1fN+V8ptzG +2mHgXEm8EPLQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E7A3B180052 for ; Thu, 22 Aug 2024 21:34:06 +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.1 required=5.0 tests=BAYES_50,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 fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) (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, 22 Aug 2024 21:34:06 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 0A5B61151BBC for ; Thu, 22 Aug 2024 17:32:15 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Thu, 22 Aug 2024 17:32:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; 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=fm1; t=1724362335; x=1724448735; bh=O7R58WhIOs Kh+rJ0mXXA4Zog6f3+lImYUSEbMsLM9e0=; b=ZECvWOnBC1n3/UUaaeuZKtsw86 YPz8S64E43t9MHePyIs/PAdFWq74Cqi5aUYO1NAGi81hRX+YHZ405WAnMF09+d7F 3UgjYNZxVrplPnOwAlIpiO4/cZjIK132bJ8C8FycWjcoqnc+3H2ylHZpmkSSqVy9 uHYTln7SZP8Jw1BghYil3x/JiPtxh7/zZ5WZkMBgyzSuQpUvhHRCRmGkUeG70SES lHJLqNUW5n+ihoDreO9/4rcLuwflUivLZmtOjc7Ebx5li7jMU4wvaDGuK7GXh1Ph s0kT/mpNZnhz/t6Zp65/AmHITCMMJcKObHCi0310hdUaUMhwvgzz6eJ1klQQ== 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=1724362335; x=1724448735; bh=O7R58WhIOsKh+rJ0mXXA4Zog6f3+ lImYUSEbMsLM9e0=; b=K+M0UPw69KEteaFg42W2OzCkdFWxm7ljxBiVrsMGRzCd Y3Zpb3vsgqsrwZ2SslgFjX5FBVKHiM0ur7dntPS+cRMmUeFfau6AdGn5nPR+dB1J O8ExY1D7upWGQFYbCdnFZ46rqZPmnebtxJBFTVfLXYXAatIzPSme4DIAjrj0uMpv H3tfe0g/WXM/WEe78fjK5nXb2VtQaT6b6A7FcP7y1Se+pjHqt+RJUGq+JkC2HmTO WUfh80X6smQtRsttmnkeqrBlezinKwWV8gBPgGXs9xWbsYm/zde2m08k0Io3355S M6A2aqiK49kLYqIzfArcwCI3DRBNvvVsIhR4NhgTlw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvtddgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkff ggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhn shculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenuc ggtffrrghtthgvrhhnpeehteelieeigfeuudeiueeiffdvveehudeufeekjeeugffffedt iedtgeettdelteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthhtohep uddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhish htshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 22 Aug 2024 17:32:14 -0400 (EDT) Content-Type: multipart/alternative; boundary="------------hwQLVXoiIWhTgx6vIyVXmpM0" Message-ID: Date: Thu, 22 Aug 2024 22:32:13 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") This is a multi-part message in MIME format. --------------hwQLVXoiIWhTgx6vIyVXmpM0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 04/08/2024 18:41, Ilija Tovilo wrote: > * Prefix your calls with namespace\. That's quite ugly, but is the > syntax we currently offer. I was thinking about this earlier, and how the migration is pretty much the same (and equally automatable) in either direction: * If unqualified calls become always local, then every global function call needs a use statement or prefixing with "\". * If they become always global, then every local function call needs a use statement or prefixing with "namespace\". But the first option probably requires changes in the majority of PHP files in use anywhere; whereas the second only affects a small minority of code bases, and a small minority of code in those. BUT, if people already complain about "\" being ugly, having to write "namespace\" is going to make them REALLY grumpy... So maybe at the same time (or, probably, in advance) we need to come up with a nicer syntax for explicitly referencing the current namespace. Unfortunately, finding unused syntax is hard, which is why we have "\" in the first place (and for the record, I think it works just fine), but maybe something like "_\" could work? Giving us: namespace Foo; $native_length = strlen('hello'); # same as \strlen('hello') $foo_length = _\strlen('hello'); #  same as \Foo\strlen('hello') If I had a time machine, I'd campaign for "unqualified means local" in PHP 5.3, and we'd all be used to writing "\strlen" by now; but "unqualified means global" feels much more achievable from where we are. -- Rowan Tommins [IMSoP] --------------hwQLVXoiIWhTgx6vIyVXmpM0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 04/08/2024 18:41, Ilija Tovilo wrote:
* Prefix your calls with namespace\. That's quite ugly, but is the
syntax we currently offer.


I was thinking about this earlier, and how the migration is pretty much the same (and equally automatable) in either direction:

* If unqualified calls become always local, then every global function call needs a use statement or prefixing with "\".
* If they become always global, then every local function call needs a use statement or prefixing with "namespace\".

But the first option probably requires changes in the majority of PHP files in use anywhere; whereas the second only affects a small minority of code bases, and a small minority of code in those.


BUT, if people already complain about "\" being ugly, having to write "namespace\" is going to make them REALLY grumpy...

So maybe at the same time (or, probably, in advance) we need to come up with a nicer syntax for explicitly referencing the current namespace.

Unfortunately, finding unused syntax is hard, which is why we have "\" in the first place (and for the record, I think it works just fine), but maybe something like "_\" could work? Giving us:

namespace Foo;

$native_length = strlen('hello'); # same as \strlen('hello')
$foo_length = _\strlen('hello'); #  same as \Foo\strlen('hello')


If I had a time machine, I'd campaign for "unqualified means local" in PHP 5.3, and we'd all be used to writing "\strlen" by now; but "unqualified means global" feels much more achievable from where we are.

-- 
Rowan Tommins
[IMSoP]
--------------hwQLVXoiIWhTgx6vIyVXmpM0--