On 07/05/2025 14:10, Tim Düsterhus wrote:
And rewrite all references inside of `Foo` to `Foo$Bar` (using Java's name mangling). This is effectively what Ilija's proposal for file-private classes did: https://externals.io/message/126331#126337. I think this would also be nicer on the autoloading impact. Since a private class is not usable outside of its container class, it doesn't make sense to attempt to autoload it individually, since to reference it, the container class must already be loaded (which means the private class is also already loaded).


I agree that this would be possible; I disagree that it is essential, or that it has anything to do with consistency with the rest of the language.

I'm not even sure if it would be a good idea - it would mean having what appears to be a fully-qualified name actually "shadowed" by a completely unrelated definition within a particular scope. For example "\Foo\Bar" would still refer to "namespace Foo, class Bar" in most of the program, but "class Foo, nested class Bar" in the context of class Foo. If the visibility was changed to "public", the shadowing would instantly become a conflict anyway; and I can't picture how "protected" would work.


--
Rowan Tommins
[IMSoP]

Reply via email to