I would like to do something like this, but I wouldn't require extension. If I do struct TopLevel.SecondLevel { ... } it could already check if there's a TopLevel somewhere and extend it automatically. I think it's fine to omit extension in this case as we're not really changing the type, we're only using its namespace.
Is that right? I'm not sure I see the syntactic benefit to the alternate form. The current syntax is just as clear and concise.
Yes, the current system makes you write out some boilerplate-looking structure when you're nested four layers deep in structs that have no members and don't do anything. But in real code, each of these layers would have actual content and the structuring would not be unwelcome. Besides, there's nothing to stop you from writing it all out as one extension anyway...
I've wanted this syntax for a long time (without the extension prefix as @DeFrenZ mentioned). For me it's mostly a matter of indentation consistency. It's somewhat unfortunate that the body of struct A gets indented one level while struct A.B gets indented two levels. Not a critical issue, but it would be nice to allow top-level and nested types to be symmetrical in this sense, and I don't see any real downside to it.
Apparently TopLevel and FirstLevel in your example aren't semantically and structurally related whatsoever, which means there isn't even a need for nesting them – the main problem discussed in this thread. That said, what's the point of your example?
Oops top level is a class - makes sense then - acts like Java inner class but avoids deep nesting with can be hard to follow at the expense of holding a pointer.
...isn't even a workaround. It is as wrong as it would be to make Collection.Indices into simply Indices. Right now, the only correct method to semantically and structurally express the belonging of one type to another is nesting them or extending one. The whole point of such a relationship is for the nested type to be referred to as A.B outside the type it belongs to and simply as B within. Properties and methods act under the same rules. This thread proposes a usage convenience for this concept.
It seems like this concept has its supporters, and it’s detractors fall mainly in the camp of, “I wouldn’t use it” or “is it really useful?”.
I’ve not heard any philosophical arguments against it. And more importantly no technical reasons why it wouldn’t work.
If there are no major objections or technical areas we haven’t considered, I will start to investigate the feasibility of implementing it for a formal proposal.