Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125064 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 DBCF21A00BD for ; Tue, 20 Aug 2024 08:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724140997; bh=ji+Fo2VOXXPzylQZ68U+awo52jZtNf3ty7TPBQBOwCc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=R9V3mHl0LqJmEg2PSLbXaCamT1gHrajT7i8PxCsGb2FUfIO8Xf29/ueyMtf9zdHEU JYSqniPQGcftPRRHJnHJ4J9p4qUWUhC6qJHBTzRU9Fq5cz3CNH74q1zTn11f8FRnWH RTaDQxUzV9vDC2DBXLjAZZoNLudjuwluFLDmwAjaU0AWU5dVqFQVC+/Yw/rqK+codd QfuJ4WMJnfuvef/O+QBpw7FRlpSvALhJHB36XdLo3+N3kR2T6SWLmHDUM1+gMeZS01 hwQxXdRDoi71B56MCJP1VD7Lgt86kkifTXUZ7aNaYrOFsSogC4rjEpI25Om4MLefTg q7LCBxPbL0puA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 43EB3180071 for ; Tue, 20 Aug 2024 08:03:17 +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,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (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 ; Tue, 20 Aug 2024 08:03:16 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e117059666eso4874854276.3 for ; Tue, 20 Aug 2024 01:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724140887; x=1724745687; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ji+Fo2VOXXPzylQZ68U+awo52jZtNf3ty7TPBQBOwCc=; b=TC3t+vEQusTSaFhtdZYRZPF0nvDe13MIYhbN4AFXi+Uni7AQNN3dtGE5PcNxd34wdQ IUigcvpcr4BJXxWlV2gUCjzebl/pP2WPlCd20XwVrc4/OA04Fkuwy4Z5e+LHdN0yr/+j jJUCaMR0tiXtnXknzR+CzsH5NAR4TKrg8lkuVVyJssGBOGAeW6+BDmhjbJG9pC5Ooqlr 0dcwPamn7FD8QmWKAQU2VzS1zggNTaL4VhK6Yu3Fj/jIMTGt+dXnzUjRW7dXo4E2a5u5 ixFglvK9C3FvmBaYy6Ewd9Gfuc8V25fdSBYzjggVSLNz5kAw7gNJK++/A6kzk0c3xArC HHHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724140887; x=1724745687; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ji+Fo2VOXXPzylQZ68U+awo52jZtNf3ty7TPBQBOwCc=; b=f30EtotPFHot6MJNHy0nfl3dB7djx38VFwrF/8LSKm7mhfUNvWjkGmJkne4RtGkuUq sDh8ZbFgdKzljL9UrHlx5qM/P+ON1OqZM5LB3QMpPIvPFaP/EOdhSxNWriclwxFQqART S+vjVwp3JmVxpvciwvxiOxQSpJak81c/RgjKHUQV2TEwgI5Wt+ItZGfR/YLRtTbvno7p jSAwHF8XghLMjze5OLSkAVQnsUGfDOUKMMyQArmMU4AlaLsrMz1oAWxUkUqakTVrP4Yc 8y2FFZMp7E0KrDlNstJnRBjxipp9Mn/VDqOC8OuJhXhYbQD2pCKk0DwYoAtfELBGYhTh hCTg== X-Gm-Message-State: AOJu0Yz8wEgTDGbxnTfLO6wz50xP1u5MDaxwwu0B0rUXtrZbQQ8/k7BE Zot9Wc5QG0CoYC6RorftaqFEz0YCY9dRgW1J7SjK/yeqBy6Q8Qr99vOqC9WSA+91Wv2lRoVP9hC Lue3hRsSp+wew9lTpDDO6FekXeR87cus4v4A= X-Google-Smtp-Source: AGHT+IH4+8cAr6gSN0wcTQR0hW20AR4ykl3Fh5mgfSzYQv6RNJIS7YXjGISpprCI3ZIfDolNi9sB9CIMm9uLMrjlRXA= X-Received: by 2002:a05:6902:2183:b0:e16:339c:d0ae with SMTP id 3f1490d57ef6-e16339cd1b2mr5005216276.23.1724140886780; Tue, 20 Aug 2024 01:01:26 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 20 Aug 2024 11:01:10 +0300 Message-ID: Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) To: Ilija Tovilo Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000197888062018d59b" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000197888062018d59b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Aug 4, 2024 at 8:43=E2=80=AFPM Ilija Tovilo wrote: > Hi Rob > > On Fri, Aug 2, 2024 at 7:10=E2=80=AFPM Rob Landers wr= ote: > > > > So, what you=E2=80=99re saying is that symfony and laravel can get a pe= rformance > increase by simply adding a \ in the right places? Why don=E2=80=99t they= do that > instead of changing the language? > > Nothing, of course. However, a Symfony maintainer has expressed > uninterest in prefixing all internal function calls, including > automated use statements at the top of the file. Even if they did, > most users will not. > > Function lookup in either global or local scope is problematic, and probably that's why we don't have autoloading for functions yet. How about we change the language so that in PHP 9.0 there will be a notice that gets triggered when a fallback to the global namespace gets triggered. We would upgrade that to a warning in PHP 9.2, and it would end up being an error on PHP 10 and have a BC break. I don't think adding a \ to each function call is ugly, that's what we have for classes, and it works fine; or an use statement. So, why do we think that after people get used to it, they would still consider it ugly? Never heard the "ugliness" mentioned for classes. Now, I know this would be a big BC break, but it brings consistency to the language and forces everyone to improve their code performance. If that's not acceptable, then maybe considering all unqualified functions as belonging to global namespace only might be an alternative solution. That means that non-global functions must be imported or be fully qualified, and that would be a BC break as well, but a smaller one. To sum up, I think we need to remove the fallback behavior, so we can have better things in the future. Either keep only local with a bigger BC break but a better language consistency. Or keep only global with a smaller BC break. Regards, Alex --000000000000197888062018d59b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Sun, Aug 4, 2024 at 8:43=E2=80=AFPM Ilija Tovilo &= lt;tovilo.ilija@gmail.com>= wrote:
Hi Rob
On Fri, Aug 2, 2024 at 7:10=E2=80=AFPM Rob Landers <rob@bottled.codes>= ; wrote:
>
> So, what you=E2=80=99re saying is that symfony and laravel can get a p= erformance increase by simply adding a \ in the right places? Why don=E2=80= =99t they do that instead of changing the language?

Nothing, of course. However, a Symfony maintainer has expressed
uninterest in prefixing all internal function calls, including
automated use statements at the top of the file. Even if they did,
most users will not.


Function lookup in either global or lo= cal scope is problematic, and probably that's why we don't have aut= oloading for functions yet.
How about we change the language = so that in PHP 9.0 there will be a notice that gets triggered when a fallba= ck to the global namespace gets triggered.
We would upgrade that = to a warning in PHP 9.2, and it would end up being an error on PHP 10 and h= ave a BC break.

I don't think adding a \ to ea= ch function call is ugly, that's what we have for classes, and it works= fine; or an use statement.
So, why do we think that after people= get used to it,=C2=A0they would still consider it ugly? Never heard the &q= uot;ugliness" mentioned=C2=A0for classes.

Now= , I know this would be a big BC break, but it brings consistency to the lan= guage and forces everyone to improve their code performance.

=
If that's not acceptable, then maybe considering all unquali= fied functions as belonging to global namespace only might be an alternativ= e solution.
That means that non-global functions must be imported= or be fully qualified, and that would be a BC break as well, but a smaller= one.

To sum up, I think we need to remove the fal= lback behavior, so we can have better things in the future.
Eithe= r keep only local with a=C2=A0bigger BC break but a better language consist= ency.
Or keep only global with a smaller BC break.

=
=C2=A0Regards,
Alex
--000000000000197888062018d59b--