[swift-dev] Protocol declaration inside a class

Виктор Шаманов wiruzx at gmail.com
Thu Dec 10 15:59:36 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, ability to declare 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-dev/attachments/20151211/e39d010a/attachment.html>


More information about the swift-dev mailing list