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

From: Date: Fri, 23 Aug 2024 10:29:32 +0000
Subject: Re: [Concept] Flip relative function lookup order (global, then local)
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Fri, 23 Aug 2024, at 10:58, Stephen Reay wrote:
> Making relative function names do the opposite of relative class names 
> sounds like a great way to permanently kill any prospects of 
> encouraging developers to use regular namespaced functions in place of 
> static classes as "bag of functions", which is what we keep hearing we 
> should use - most notably on a recent RFC to embody the concept of a 
> static class.

That's why I brought up the point about making it easy to explicitly say "relative to
current", just as you can explicitly say "relative to global" with a single
"\".

It's also worth remembering that this whole discussion has no effect on using functions that
are defined in a *different* namespace. The below code might benefit from function autoloading, but
would not be helped, hurt, or changed in any way by any of the proposals in this thread:

namespace Acme\Foo\Controller;

use function Acme\StringUtils\better_strlen;
use Acme\StandardUtils as Std;

$foo = Std\generate_something();
$len = better_strlen($foo);
\Acme\Debug\out($len);



Regards,
-- 
Rowan Tommins
[IMSoP]


Thread (112 messages)

« previous php.internals (#125120) next »