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

From: Date: Fri, 23 Aug 2024 11:50:10 +0000
Subject: Re: [Concept] Flip relative function lookup order (global, then local)
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-125125@lists.php.net to get a copy of this message
On Fri, 23 Aug 2024, at 12:29, Mike Schinkel wrote: > namespace \AcmeComponents\SplineReticulator\Utilities\Text > > function Foo():int { > return Text\strlen("Hello World"); > } > > The above of course could result in BC breaks IF there happened to be > existing code that referenced Text\strlen() where Text was a top-level > namespace 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\..."). It's an interesting suggestion, but I'm not totally sold on "use the end of the current namespace" being easier to remember than "use this symbol or keyword". return namespace\strlen("Hello World"); # current syntax, rather long and unclear return _\strlen("Hello World"); # short, but maybe a bit cryptic return Text\strlen("Hello World"); # variable length, relies on current context return NS\strlen("Hello World"); # shortening of current keyword return self\strlen("Hello World"); # maybe confusing to reuse a keyword? return current\strlen("Hello World"); # clear, but a bit long -- Rowan Tommins [IMSoP]

« previous php.internals (#125125) next »