I believe it's prettier in code appearance because it removes unnecessary indentation. If we add an extension to Settings right below it, the indentation level will be different from the actual Settings definition. But this approach removes the indentation. I think it is also better in readability.
Do you have an opinion about this? Is it reasonable? Can it be implemented in Swift? What are the positive and negative consequences?
I almost always write a separate extension that has a single nested enum/struct/class declaration, so this would mean a very noticeable code readability benefit for code bases like mine. Also, this seems like a harmless, easy-to-implement and obvious syntactic sugar!
This has been discussed a few times in the past, but I don't believe anyone has taken it as far as writing up an official proposal and implementation. I'd love to see it happen since the syntax would pair nicely with the use of extensions to organize code.
Hi,
First, I'm sorry for the duplicate. I exactly searched for the phrase "nested types" and these topics didn't come up.
I'm not familiar with the process of writing proposals but I'm ready to work on it. There are some parts in the proposal that I need to consult with someone familiar with the topic, such as effects on ABI stability. If anyone can help me with the proposal, I appreciate it.
I've worked in a large codebase that uses nesting extensively for several years now, I can say that IMO the step forward would be larger than it appears.
Agree, typealiases should be supported in addition to types. Other kinds of declarations are probably a step too far:
So I guess you've bumped into this a lot then, unless you started after 5.0.
I agree, what I meant was that the proposed feature seems like a small step conceptually (and perhaps even implementationally) from what's currently possible, but that it is (potentially very) nice for readability etc. : )