Protocol declaration inside a class


(Виктор Шаманов) #1

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