[swift-evolution] Protocol declaration inside a class

Виктор Шаманов wiruzx at gmail.com
Thu Dec 10 16:25:50 CST 2015


Happy Friday everyone!

I wonder why the protocol declaration should be only at the file scope?
Is this a design choice or limitation of the current implementation?

I think, the ability of declaring protocols inside the other declarations
would improve readability and code-organization.

For example, instead of:

protocol UITableViewDelegate {
...
}

class UITableView {
    var delegate: UITableViewDelegate?
}


we would write:

class UITableView {

    protocol Delegate {
    ...
    }


    var delegate: Delegate?
}


Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151211/be3b9c9e/attachment.html>


More information about the swift-evolution mailing list