Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125052 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 51CD41A00BD for ; Mon, 19 Aug 2024 21:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724102352; bh=FrzPeCvT1yXuTOpsNME9eqi6xWc9JaayA0mmrRHwkWE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Py0Z3L/PYOzkAd8nP7/+uwSaYHYXxBSUt2gOCymDwvwkXacnHyPDmK9yklpY5iBPM bO9ajzYUndLId//E3FZmBtoDaLL3rmIhY5l9gG7NnCULrWtVfhpwWrGSSAwpFC0QhL B3RNoUzcDFhmFtPbXcwjlO8lUMWrKXyrPDK60q5pzzqZetuKmXPOhe1tXGknVfjYQn wbbP2NNg/oBUfFMo6jGKaRAKICKsnRStFBdnQJormPBlrNjPCoDa6IsE1Y6LLcFkLa 10vV2xMSh581v8jXQt2iASw6fCjuYwLFS7GHQFn79pMDFflOVLxOLz/YeR7no7Y6az B7uPH3Ir7WCNA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1AD7918005C for ; Mon, 19 Aug 2024 21:19:11 +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,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh6-smtp.messagingengine.com (fhigh6-smtp.messagingengine.com [103.168.172.157]) (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 ; Mon, 19 Aug 2024 21:19:10 +0000 (UTC) Received: from phl-compute-06.internal (phl-compute-06.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 0B53511519EA for ; Mon, 19 Aug 2024 17:17:21 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Mon, 19 Aug 2024 17:17:21 -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=1724102241; x=1724188641; bh=mZ6ECkun60b7CJ64vbdMccE3lT2++Ezw/n+yvAsithk=; b= O294Uf1v5f6mLwvrTUlxdWlLdTveiv87pm8tT4iXsM862pWGIUFJVMCfqV4cbQYH yBfts3HMY1uBCNFY/UXcdFya8k61ocNwCbqc5L/MQEh4AMlS4cVQVzwRd0+X9dCX f1G9Ee2lVzL02pa92hqS03pT/MxiyoYxDCQ2WRmz0PJ87arecN65vwQHpQenD5YF NnvZxwEEcmGRmomaOSGusF2SUXVD6hYfPFEm6MNr/3YhHQUvY/izu94gUdPaSFkl dP3GV2k3TkYfWjcoRf8UbSuDFMj1e0OH4bwyNiMmp+CxM30VWcE5UQw04r/Qo0wt hfHij1qmjIZOvvL3XHBjnw== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1724102241; x= 1724188641; bh=mZ6ECkun60b7CJ64vbdMccE3lT2++Ezw/n+yvAsithk=; b=B QvyzRA5eKtEee8uCyzx8pr90Dsg9rskXKtDB/b5XP17e3f5piHxTMK6B35yuWyKT vc/evZ+VaLfPzut3MyMGuP9kjlLL7z1Fcopp2JUUNe4ZTdSWMfJlLzVhB45Aqq6C eK9yfCgBBcK0jInbUa+YOablL7so07PnhxsonQNw6rhXfXL6TVVL2dt2hu3bMb0h K9tSF8FXsTvVabMhvcaKPzZnPbhY+sAT69cwVojBU9plsg/+rX/VecWY02ZCq3xt yJ9gpHA41hgGK5pJboZEVqge6pbtuimqlKbb8hmDqzCqlh2kbKOBT9fHsZesFjt7 3c1GgIVgnHx+gjPNc4bLA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddugedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecuogfuuhhsphgvtghtff homhgrihhnucdlgeelmdenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdej necuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceoihhmsh hophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeejgefgheej veeklefhudfgffetveegjeehtefgteeuieehgeevtdehlefhhfeuueenucffohhmrghinh epfehvgehlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtth hopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehl ihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 19 Aug 2024 17:17:20 -0400 (EDT) Message-ID: <6197f6e1-d123-41e1-87c8-887c6508bfa2@rwec.co.uk> Date: Mon, 19 Aug 2024 22:17:19 +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] function autoloading v4 RFC To: internals@lists.php.net References: <2716f729-4008-4f75-8412-861d8960b746@app.fastmail.com> <26338153-6d16-456a-81bf-8231bdaf1b79@app.fastmail.com> Content-Language: en-GB In-Reply-To: <26338153-6d16-456a-81bf-8231bdaf1b79@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 19/08/2024 17:23, Rob Landers wrote: > As far as performance for ambiguous functions go, I was thinking of > submitting an RFC, where ambiguous function calls are tagged during > compilation and always resolve lexically, sorta like how it works now: > > echo strlen($x); // resolves to global, always > require_once "my-strlen"; > echo strlen($x); // resolves to my strlen, always > > This works by basically rewriting the function name once resolved and > may make the code more predictable. If I can pull it off, it can be > relegated to a technical change that doesn’t need an RFC. Still > working on it. I'm not entirely clear what you're suggesting, but I think it might be either what already happens, or the same as Gina is proposing. Consider this code [https://3v4l.org/184k3]: namespace Foo; foreach ( [1,2,3] as $i ) {      echo strlen('hello'), ' ';      shadow_strlen();      echo strlen('hello'), '; '; } function shadow_strlen() {     if ( ! function_exists('Foo\\strlen') ) {         function strlen($s) {             return 42;         }     } } In PHP 5.3, this outputs '5 42; 42 42; 42 42;'  That's fairly straight-forward: each time the function is called, the engine checks if "Foo\strlen" is defined. Since PHP 5.4, it outputs '5 42; 5 42; 5 42;'   The engine caches the result of the lookup against each compiled opcode, so the first strlen() is cached as a call to \strlen() and the second as a call to \Foo\strlen(). As I understand it, Gina is proposing that it would instead output '5 5; 5 5; 5 5;' - the function would be "pinned" by making "\Foo\strlen" an alias to "\strlen" for the rest of the program, and the function_exists call would immediately return true. Neither, as far as I can see, can happen at compile time, because the compiler doesn't know if and when a definition of \Foo\strlen() will be encountered. > In other words, maybe pinning could be solved more generally in a > future RFC, decrease your RFC’s scope and chance for sharp edge cases. If anything, I think it would need to be the other way around: change the name resolution logic, so that an autoloading proposal was more palatable, because it didn't require running the autoloader an unbounded number of times for the same name. Proposing both at once seems reasonable, as the autoloading gives an extra benefit to outweigh the breaking change to shadowing behaviour. Regards, -- Rowan Tommins [IMSoP]