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

From: Date: Fri, 23 Aug 2024 12:33:45 +0000
Subject: Re: [Concept] Flip relative fu nction lookup order (global, then local)
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


On 23 August 2024 13:04:22 BST, Mike Schinkel <[email protected]> wrote:
>
>> It wouldn't be a top-level namespace that would cause a conflict, but a nested one:
>> currently the above code resolves the function name as
>> "AcmeComponents\SplineReticulator\Utilities\Text\Text\strlen" (note the
>> "...\Text\Text\...").
>
>How often does that really occur in the wild?  

Oh, I think it would be much rarer than colliding with a global namespace. I was pointing out that
your suggestion was *better* than you thought.


>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".


>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.


>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

Rowan Tommins
[IMSoP]


Thread (112 messages)

« previous php.internals (#125132) next »