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

From: Date: Fri, 23 Aug 2024 12:45:38 +0000
Subject: Re: [Concept] Flip relative function lookup order (global, then local)
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
> On Aug 23, 2024, at 8:33 AM, Rowan Tommins [IMSoP] <[email protected]> wrote:
> On 23 August 2024 13:04:22 BST, Mike Schinkel <[email protected]> wrote:
>> And how can it occur without an explicit use
>> AcmeComponents\SplineReticulator\Utilities\Text\Text statement, which I proposed would
>> override the automatic use, anyway?
> 
> I'm not sure what you mean. Right now, that's the function name that would be looked
> up for your example code (other than a couple of unrelated typos in your example). So if, for some
> reason, someone was relying on that, their code would break with your "automatic use".

I must be missing something.  Can you give a specific example showing how the automatic use would
conflict with something other than a root namespace?

>> The only one of those that has a strong analog to existing PHP code is to "use the end
>> of the current namespace" as people frequently do with explicit use statements.
> 
> True. I just don't love the context-sensitive nature of it.

Well, we frequently see things differently, which is what it is. 

Myself, I like the explicit nature of it that allows seeing at a glance that it is Text without
having to look up through a long PHP file to find the namespace statement.  But as my dad says, to
each his own, I guess.

Besides, I think there may be some better solutions discussed on this thread besides our dueling
qualification syntax.

>> Lastly, no comment on \\?
> 
> Ah, yes, I forgot to say: I'm not keen on that because in other contexts it means exactly
> the opposite: it refers to the absolute root in a context where a relative name would be assumed.
> 
> For example, \\domain\username and \\server\fileshare on Windows, or //example.com/foo in a URL

Fair point.  But then treating built-ins differently than userland globals may be the way to go that
has the least BC breakage over either of our two proposals here.  

That said, having an automatic use would be nice for those who want to use it, even if
it is not required.

-Mike


Thread (112 messages)

« previous php.internals (#125134) next »