On 13 June 2026 16:32:08 BST, Michael Morris <[email protected]> wrote:
>Namespaces in PHP are a bit of a hack - they prepend the stated namespace >to all labels declared in the file, and the use statement allows the fully >qualified name of a class, function or constant to be stated only once, >usually at the head of the file. It also allows aliasing, say if you have a >"Parser" class out of two different packages - you can alias them as >"FooParser" and "BarParser". It looks like Java or JavaScript importing, >but it isn't. A small correction: this is exactly the same way that namespaces work in Java, with exactly the same implication: the fully qualified class name has to be globally unique. Java's solution to isolating an entire set of names is apparently to define an "Isolated ClassLoader": https://www.javathinking.com/blog/what-is-an-isolated-classloader-in-java/ C# also has this model of namespaces, but allows you to isolate a set of names from a particular "assembly" using an "extern alias" statement: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias I suspect both mechanisms rely on details of their respective runtimes that wouldn't translate to PHP, but in principle what we're looking for is something similar. Rowan Tommins [IMSoP]
