On Sun, Aug 4, 2024 at 8:43 PM Ilija Tovilo <tovilo.il...@gmail.com> wrote:
> Hi Rob > > On Fri, Aug 2, 2024 at 7:10 PM Rob Landers <rob@bottled.codes> wrote: > > > > So, what you’re saying is that symfony and laravel can get a performance > increase by simply adding a \ in the right places? Why don’t 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