# An Implementation Model for Rational Protocol Conformance Behavior

**URL:** <https://forums.swift.org/t/an-implementation-model-for-rational-protocol-conformance-behavior/37171>\
**Category:** Pitches\
**Tags:** generics\
**Created:** [June 3, 2020, 12:38am UTC](https://forums.swift.org/t/an-implementation-model-for-rational-protocol-conformance-behavior/37171 "2020-06-03T00:38:15Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [June 5, 2020, 5:19am UTC](https://forums.swift.org/t/an-implementation-model-for-rational-protocol-conformance-behavior/37171/20 "2020-06-05T05:19:11Z")

</div>

> [@mattrips](#):
>
> I want to stay focussed on the question you pose about how we think it ought to work: "Is that really the interpretation we want?" I suppose my answer is, I could go either way on the interpretation. But, whatever the interpretation, I think it ought to apply the same way to both your example and my example.

In your example, when `Array` conforms to `P`, the `Array` version of `whatAmI()` is the most specialized already, so you get the right answer. Add this to your example and it will better parallel @jrose's:

```swift
extension Array where Element: P {
  func whatAmI() { print("Array<P>") }
}
extension Int: P {
  func whatAmI() { print("Int") }
}

```

The output will be:

```swift
Array<P>
Array

```

That's the one that bothers me most. A protocol requirement is meant to be a point of dynamic dispatch, where you jump to a version of the code that's been customized for the concrete type... but we don't actually get all of the customization we want (or expect).

I'm less bothered by @jrose's example because I don't feel like a call to a function that is neither an overridable method in a class or a protocol requirement should allow different behavior with different types at runtime.

I appreciate that we're gathering a corpus of examples and opinions. One needs those to evaluate designs.

Doug

---

_[View the full topic](https://forums.swift.org/t/an-implementation-model-for-rational-protocol-conformance-behavior/37171)._
