# Pitch: Protocols with private fields

**URL:** <https://forums.swift.org/t/pitch-protocols-with-private-fields/51209>\
**Category:** Pitches\
**Created:** [August 14, 2021, 11:45am UTC](https://forums.swift.org/t/pitch-protocols-with-private-fields/51209 "2021-08-14T11:45:03Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![dabrahams](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dabrahams/32/9815_2.png) [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Post date:** [December 5, 2021, 7:05pm UTC](https://forums.swift.org/t/pitch-protocols-with-private-fields/51209/15 "2021-12-05T19:05:51Z")

</div>

> [@Alvae](#):
>
> However, I would like to expose the conformance, only **without** having all internal details exposed (in particular w.r.t. mutation) at the same level.

Sure. I just wonder if the same thing might not be accomplished by composing public protocols, but using one private or internal conformance. What I have in mind is,

```swift
// Module A
public protocol X { ... }
public protocol EasyXImpl {}

extension X where Self: EasyXImpl {
  // implementations of X requirements in terms of EasyXImpl requirements
}

// Module B
import A
public struct Y: X private EasyXImpl {
  // EasyXImpl requirements
}

```

That would have a few advantages:

1. The protocol system would retain its simplicity
2. A protocol would have a single, well-understood meaning that doesn't change across access levels
3. We'd avoid adding another language feature, since I believe we [need scoped conformances](https://forums.swift.org/t/improving-sendable/52377/22) anyway.
4. You'd still have the option to create `X` conformance without `EasyXImpl`. In fact there might be several `EasyXImpl` variants for different means of achieving that conformance.

---

_[View the full topic](https://forums.swift.org/t/pitch-protocols-with-private-fields/51209)._
