Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124754 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 88E971A00B7 for ; Mon, 5 Aug 2024 08:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722846232; bh=bu80pZjg5cBfX8jIwwxR0S2ka7nhLsicQ+5n3f3Eqvo=; h=Subject:From:To:Date:In-Reply-To:References:From; b=naE4LTtQOpzi6Ayy33ihQlEChtTUgX9JVYtpgtetyXY+Uuq0oYE4mzwmGjMSOgreZ furs+IgIWGncG0SVEclQiWDuA5iuvLcgv5bG7NgmfLkpea8si2caa7sdB8EOUnvd1k iK1MJKq053tqVjpHusWFkHphUXEzNEgecL8KyjY1DeeoFkrS1O4Xpm/2xt97fDuYO6 qaIOOBO9nn241D3dpzojC5/ZvrZDcL6YQW7jgoPc5rMCXX/H4ViEGCE2bq3qUcCVdO 2wcyZXMOUDeztqfbyuKQCvO9n65yLQt05glUkua3BArvtfEWDW8QDhWbXUL6Uad88C qt6lKOkPQCMhA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 96589180079 for ; Mon, 5 Aug 2024 08:23:51 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from ageofdream.com (ageofdream.com [45.33.21.21]) (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, 5 Aug 2024 08:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ageofdream.com; s=ageofdream; t=1722846128; bh=bu80pZjg5cBfX8jIwwxR0S2ka7nhLsicQ+5n3f3Eqvo=; h=Subject:From:To:Date:In-Reply-To:References:From; b=T82kDpPYpY/fdbhb4Y9lcEL4v0HVgJozSiy2B37X+5y7UGPLq9Q4WTax5Y1BMqr8X wT0kFaSuSzGJseafqZjaNqWTc09GFb8BJEycQ7nYlWvjKJDHN2YtmBvfEOHqKI7y7P zEY3VUiMiM7aiRXgsp2K0XKjIuikA62ZYCEMvw3bcVEu9fVxVQs0glZYftuqc7+SwO kjtmIvLmbF0VSm+YvzXvJZKfLqhMhYmmdLVUH84EFDzHk+PXXqDiOQzwIMKHFnjuK0 RVbhXNZYwsrU9+ZkIa2au2047WovzVZ+qT+0aOImSkoxS+pB6WH5OCiizN57I8c9pf rJVx3M+HndzTA== Received: from [192.168.1.7] (unknown [72.255.193.122]) by ageofdream.com (Postfix) with ESMTPSA id D20102746E for ; Mon, 5 Aug 2024 04:22:08 -0400 (EDT) Message-ID: <599a445530357d080cb59c9443cacd5cfd5da82f.camel@ageofdream.com> Subject: Re: [PHP-DEV] [RFC] Add Directive to Make All Namespaced Function Calls Global To: internals@lists.php.net Date: Mon, 05 Aug 2024 04:22:08 -0400 In-Reply-To: References: <1a88918e-e808-d778-45e1-53797660e093@php.net> <3563cf9b-8eab-4c82-b525-a5d2f9a767bb@varteg.nz> <38920A4B-790D-48C7-B2F6-C49D3F506232@rwec.co.uk> <0824789d-0e36-4628-85c1-4b8d9b7f86af@varteg.nz> <2244a37f-8c51-448d-8a56-329ff32e6470@bastelstu.be> <0e1a21ddef3c7da17a3539b92d5f442763f4b1f8.camel@ageofdream.com> <5f1da5195e2aea7ec41e95ff4354f50b1717d3cf.camel@ageofdream.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 From: lists@ageofdream.com (Nick Lockheart) > >=20 > > I did not intend for all unqualified calls to become global, unless > > the new directive is present. >=20 > Sorry, my language was not precise enough. Your proposal suggests > making unqualified calls global when the directive is present, > whereas my proposal suggests keeping local scope as a fallback, hence > the two not being compatible. Keeping local scope as a fallback would still require an NS lookup opcode. My proposal is that there still be an NS lookup as the default behavior, but allow an optional override. That is, users would have three options: (1) resolve all unqualified function names to global (no NS lookup) (2) resolve all unqualified function names to local (no NS lookup) (3) Use the default behavior, which at present, is local first, then global, with a namespace lookup. (no change to user code, keeps BC) Your proposal reverses the order of the default NS lookup from local first to global first. That's not mutually exclusive. If my proposal *and* yours were *both* accepted, users would have these options: (1) resolve all unqualified function names to global (no NS lookup) (2) resolve all unqualified function names to local (no NS lookup) (3) Use the default behavior, which would now be global first, then local, with a namespace lookup. (no change to user code, keeps BC working, but changes the default automatic lookup order) I believe that my propsal also helps yours be more viable, too. Because if your proposal was accepted alone, and the NS lookup order changed, then it would no longer be possible to do unit testing with stubs that replace built-in functions, UNLESS there was also an option for developers to instruct the compiler to use local functions over global ones. >=20 > What I'm saying is that: >=20 > 1. If the vote fails, it might have been because some people don't > want opt-in behavior. Niels just voiced this opinion. Every token added to a PHP file is opt-in behavior that changes how the parser works. > 2. If the vote is accepted, it would void my suggestion, because it > is not compatible with the conditions laid out in your proposal. I don't see them as being incompatible at all, they would actually work together. An automatic performance improvement for everyone without any BC breaks or code changes, plus a new option that gives advanced developers a new tool to write cleaner class code, and enable advanced unit testing tools to work. >=20 > A vote with multiple options to pick an approach (opt-in through some > directive, hard BC break, flipping lookup order, nothing at all) > might be more appropriate. A vote has not been called, and an RFC is supposed to be amended in response to comments and discussion. I think something needs to be at least as formal as an RFC or people won't take it seriously enough to contribute feedback. I'm trying to start a discussion on this and get some momentum so that we can hopefully implement something in a near future version. Please, let us discuss.