# What are the differences between protocols that do or don't have Self/PAT requirements?

**URL:** <https://forums.swift.org/t/what-are-the-differences-between-protocols-that-do-or-dont-have-self-pat-requirements/24036>\
**Category:** Using Swift\
**Tags:** protocols\
**Created:** [May 2, 2019, 12:59am UTC](https://forums.swift.org/t/what-are-the-differences-between-protocols-that-do-or-dont-have-self-pat-requirements/24036 "2019-05-02T00:59:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CTMacUser](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ctmacuser/32/1802_2.png) [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Post date:** [May 2, 2019, 12:59am UTC](https://forums.swift.org/t/what-are-the-differences-between-protocols-that-do-or-dont-have-self-pat-requirements/24036/1 "2019-05-02T00:59:09Z")

</div>

I know that protocols can be used to constrain a generic parameter type. And a protocol can be used as a variable's type, a placeholder which can hold any value of any conforming type. (And for a `var`, different actual types at different times.) But a protocol with `Self`/`associatedtype` requirements cannot be used as a variable, only for a generic constraint. I understand the reason why is that types sharing a SoAT protocol have the same interface in shape, but not the same interface in the specific inner types used. Meanwhile, types sharing a non-SoAT protocol have the same interface in shape and inner types.

What other uses can you use a non-SoAT protocol type for? And other uses for SoAT protocol types?

---

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [May 2, 2019, 1:03am UTC](https://forums.swift.org/t/what-are-the-differences-between-protocols-that-do-or-dont-have-self-pat-requirements/24036/2 "2019-05-02T01:03:44Z")

</div>

There isn't a fundamental difference; this is an implementation limitation. There was a lot of discussion about this topic in this thread:

> [@Lifting the "Self or associated type" constraint on existentials](https://forums.swift.org/t/lifting-the-self-or-associated-type-constraint-on-existentials/18025):
>
> When the first seed of Swift came out many years ago, there were technical reasons for the "self or associated type" constraint on protocol existentials: At that time, protocol witness tables did not carry associated type information, so it was impossible to re-open the dynamic type in order to dispatch methods on an existential when a protocol had associated types. This was fixed a while ago in order to allow for recursive protocol constraints, but we held on to the restriction on existentials …

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [May 2, 2019, 1:11am UTC](https://forums.swift.org/t/what-are-the-differences-between-protocols-that-do-or-dont-have-self-pat-requirements/24036/3 "2019-05-02T01:11:40Z")

</div>

There's still a distinction in what you can do with members that reference `Self` or an associated type, though…

---

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [May 2, 2019, 1:38am UTC](https://forums.swift.org/t/what-are-the-differences-between-protocols-that-do-or-dont-have-self-pat-requirements/24036/4 "2019-05-02T01:38:21Z")

</div>

It's a bit subtler than that, because it isn't the Self or associated types in and of themselves that create those restrictions, but specifically the combination of using protocols as types with type-erased types in argument position.

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [May 2, 2019, 3:51pm UTC](https://forums.swift.org/t/what-are-the-differences-between-protocols-that-do-or-dont-have-self-pat-requirements/24036/6 "2019-05-02T15:51:37Z")

</div>

I feel like that's a pretty misleading statement about generics. Dave Abrahams put it this way in a past talk: "generics preserve types; existentials erase them". If you care about types, you probably want generics.

---

<div class="post-metadata">

**Author:** ![Moximillian](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/moximillian/32/3055_2.png) [@Moximillian](https://forums.swift.org/u/Moximillian)\
**Post date:** [May 3, 2019, 6:24am UTC](https://forums.swift.org/t/what-are-the-differences-between-protocols-that-do-or-dont-have-self-pat-requirements/24036/7 "2019-05-03T06:24:20Z")

</div>

> [@jrose](#):
>
> I feel like that's a pretty misleading statement about generics. Dave Abrahams put it this way in a past talk: "generics preserve types; existentials erase them". If you care about types, you probably want generics.

Sorry about that, I got the details backwards by mistake 😕
