On 17 March 2025 07:11:23 GMT, Rob Landers <rob@bottled.codes> wrote:
>
>namespace Outer;
>
>class Inner {}
>
>And
>
>class Outer {
> class Inner {}
>}
>
>These would both resolve to the same class name for Outer\Inner.
That's the frame challenge: is that actually a good thing, because it makes the
description of nested types a lot simpler?
> Which one it resolves to would depend on how you implement autoloading
That's just the same as having the same class defined in two files on disk -
PHP doesn't know which will be used until an autoloader runs.
From what I understand of the proposal, the calling code won't know anything
different based on it being "nested" or "namespaced", it will just see a class
with a long name with some punctuation in.
> Then there becomes the question of either letting user-land implement the
> autoloading changes, or have php walk “up” the namespace chain in the hopes
> it implements an inner class.
I think it should be left to the implementation - PHP makes no assumption about
one class per file anyway, so am implementation could already do this with a
namespace{} block.
It is a reasonable point that the convention for when an autoloader should walk
up, and how far, would need to be defined. Then again, I'm increasingly
convinced autoloading is a dead-end for the language, and hope to see more
enhancements to preloading and a module system instead.
> So, maybe, it could be useful to use \ but in the long run, I’m not sure it
> makes sense.
I rather think the other way round: in the short term, a new separator would
save users a bit of pain with autoloading, but in the long run it will look
like a weird anomaly that no other language needs.
Rowan Tommins
[IMSoP]