Why don't protocols in Swift use brackets instead of associated types?

Viewed 101

Why did the Swift language designers decide to make the syntax this:

protocol Container {
    associatedtype Item
    mutating func append(_ item: Item)
    var count: Int { get }
    subscript(i: Int) -> Item { get }
}

Rather than this:

protocol Container<Item> {
    mutating func append(_ item: Item)
    var count: Int { get }
    subscript(i: Int) -> Item { get }
}

The latter would seem to be much more consistent with other uses of generics in Swift.

0 Answers
Related