[swift-evolution] Proposal: Allow "flat" declaration of nested types
Jeremy Pereira
jeremy.j.pereira at googlemail.com
Mon Nov 21 04:52:45 CST 2016
> On 21 Nov 2016, at 08:42, Rien via swift-evolution <swift-evolution at swift.org> wrote:
>
> Sure you can do that, but I rather write:
>
> struct A.B {…}
>
> than
>
> extension A { struct B {…} }
>
> The first seems much “swiftier” to me.
Hmm, objectively, it’s not “swiftier” is it, because Swift has had the extension syntax since day 1 and not the dot syntax. What you actually mean is “it looks nicer to me” which is an entirely subjective position, one with which I agree, but I don’t think such arguments should carry much weight.
Actually, I’d like to see “it seems more swifty” and equivalent expressions banned from the list. The concept isn’t well enough defined for a serious discussion on the merits of proposed language features. /rant
> In fact, now that this “obvious” dot-notation has been pointed out, I wonder why this was not the initial implementation instead of the “extension” keyword.
The extension keyword is needed in the case where you are extending an existing type to conform to a protocol. Given that we already have (and need) the extension form and we can already do
extension A.B { struct C { … } }
is there an objective justification for adding a redundant way of doing the same thing?
More information about the swift-evolution
mailing list