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

From: Date: Fri, 23 Aug 2024 16:35:02 +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 23 Aug 2024, at 23:13, John Coggeshall <[email protected]> wrote:
> 
> 
> 
> On Aug 23 2024, at 11:49 am, Rowan Tommins [IMSoP] <[email protected]> wrote:
> 
> And most users don't object to using a leading backslash, they just (quite reasonably)
> have no idea what impact it has on the ability of the engine to optimise their code.
> 
> I think this is a misread, and I don't think you can argue that there is a clear
> understanding of "most users" here. While I admit I too don't have real data to back
> this up, I would be more likely to believe "most users" would absolutely object to being
> forced into using a leading backslash and would find it non-sensical that you must add a backslash
> for the engine to do the "right thing" (in this case, optimize their code with a security
> benefit), vs just doing the right thing by default.
> 

Hi John,

Now please don't misunderstand me, I am not advocating for a change to drop the fallback to
global symbols. I wouldn't be against such a change but I don't think it's a problem
that needs to be solved right now.

But if that were the proposal, I have to ask about something you said:

> would find it non-sensical that you must add a backslash for the engine to do the "right
> thing" (in this case, optimize their code with a security benefit), vs just doing the right
> thing by default. 

What do you mean by this? What is "the right thing"?

Are you saying that you think people would expect an unqualified function name to automatically act
like a global function name, and never check for a local namespaced function of the same name? Just
to be clear, you understand that is the literal opposite of how classes/traits/interfaces work in
PHP, yes?

I'm not saying that isn't necessarily how people think, I have literally zero data about
this besides my own thoughts, but it seems like a bizarre idea that people would *expect* function
name resolution to work completely opposite to how class/class-like name resolution works.


Cheers

Stephen 


Thread (112 messages)

« previous php.internals (#125150) next »