Re: [Concept] Flip relative function lookup order (global, then local)

From: Date: Fri, 23 Aug 2024 10:27:21 +0000
Subject: Re: [Concept] Flip relative function lookup order (global, then local)
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Fri, Aug 23, 2024, at 12:14, Christian Schneider wrote:
> Am 23.08.2024 um 11:34 schrieb Nick Lockheart <[email protected]>:
> > I think we are all trying to achieve the same thing here.
> 
> I'm not sure who "we" and what "same thing" here exactly is.
> 
> I recall the following arguments for changing the current situation about function look ups:
> - Performance
> - Function autoloading
> - Consistency
> 
> Did I miss something big?

Nick was replying to me :p, judging by the quoted paragraph.

> 
> First of all I don't think the performance argument holds enough weight as I'm very
> doubtful this impacts performance of a real world application in a significant way. And for people
> *really* hitting this problem there is a solution already.
> Secondly I am a bit confused about the whole function autoloading discussion: There is already
> a good-enough mechanism (putting them as static functions inside a tool class). I just don't
> consider the hoops we have to jump through to get a more "pure" or fine-grained solution
> for a special problem not worth it. As for the "don't use classes for static
> functions" I've yet to see a good argument apart from personal preference.
> As far as consistency goes I've yet to encounter someone being confused about function
> resolution. But then again I'm not reaching namespaces for PHP classes.

As far as function overloading goes, I recommend checking out a draft RFC I've been working on
a very, very long time: https://wiki.php.net/rfc/records. In some off-list
discussions, it was clear that if I wanted this syntax, I would need to pursue function autoloading.
Further, function autoloading is a clearly missing feature that would be useful in many situations.
If function autoloading doesn't work out, I will need to take a different approach to that
syntax (which is fine, but not something I want because I chose the syntax for a very good reason).
That being said, I'm not ready to discuss records here, so this is the first and last time
I'll mention it on the thread. There is a Reddit post in r/php and a GitHub repo if you are
interested in discussing records. There are very many things to work out still, and it is very much
work-in-progress.

> 
> While modern tooling possibly can adapt source code to the new style efficiently I have to
> maintain too many installations of PHP projects on various hosters to looking forward to that. And
> the argument that "you can just stay on an old PHP version" is just not a feasible
> solution either..
> 
> Maybe we should take a step back and reevaluate the pros and cons. 
> 
> - Chris
> 

— Rob


Thread (112 messages)

« previous php.internals (#125119) next »