Re: Containers. (was Re: [PHP -DEV] Two-step creation for PHP modules)

From: Date: Sat, 13 Jun 2026 17:14:18 +0000
Subject: Re: Containers. (was Re: [PHP -DEV] Two-step creation for PHP modules)
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  Groups: php.internals 
Request: Send a blank email to internals+get-131229@lists.php.net to get a copy of this message
On 13 June 2026 16:32:08 BST, Michael Morris <tendoaki@gmail.com> 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]

« previous php.internals (#131229) next »