3 ms·
Is this different from structural typing?
by nerdponx 9y ago
Is this different from structural typing?
- masklinn 9y agoWhy would you even think it has any relation?
- nerdponx 9y agoBecause it sure sounds similar. Look at Python's PEP 544, for example.
- masklinn 9y agoThe only commonality I can see is that both use the word "protocol"…
- nerdponx 9y agoAnySequence is a behavior specification, right? That seems pretty structural to me.
- mikeash 9y agoAnySequence is a concrete type conforming to the Sequence protocol. It implements Sequence by forwarding calls to some other implementation of Sequence.
- thewayfarer 9y agoStrictly speaking, AnySequence is a generic type, whereas AnySequence<Int>, AnySequence<String>, and AnySequence<Any> would be three different concrete types.
- masklinn 9y agoAnySequence is a named type conforming to a named protocol, it's all nominative. I don't know that Swift even has a structural subset.
- Froyoh 9y agoCondescending much?