# Protocol conformance for protocols with \`var myVar: MyType { get }\`

**URL:** <https://forums.swift.org/t/protocol-conformance-for-protocols-with-var-myvar-mytype-get/30745>\
**Category:** Using Swift\
**Tags:** protocols, conformance\
**Created:** [November 13, 2019, 10:52am UTC](https://forums.swift.org/t/protocol-conformance-for-protocols-with-var-myvar-mytype-get/30745 "2019-11-13T10:52:43Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![DevAndArtist](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/devandartist/32/287_2.png) [@DevAndArtist](https://forums.swift.org/u/DevAndArtist)\
**Post date:** [November 13, 2019, 11:21am UTC](https://forums.swift.org/t/protocol-conformance-for-protocols-with-var-myvar-mytype-get/30745/4 "2019-11-13T11:21:45Z")

</div>

> [@ImJustACowLol](#):
>
> But why is it in such cases necessary to go through the trouble of creating an `associatedtype` if the compiler should be able to fully infer the first code snippet I provided? To me it seems like some nice syntax sugar could be added here.

No it shouldn't, the compiler is basically only allowing you to write code exactly how you told it to with your protocol design. In the first original example you explicitly said that you want the conforming type to have a get-only property with a `Kraken` existential (a box type created by the compiler to store `any` type that also conforms to the `Kraken` protocol). Therefore the compiler awaits that you use `Kraken` and not a concrete type.  
On the other hand if you use an associated type, the compiler awaits that you tell it which concrete type you want to associated with the conformance of the protocol.

* * *

OPTIONAL:

If you're curious to learn more, there is a huge discussion on how we eventually want to improve some of the generics UI in swift which also covers some of the 'existential' and 'opaque result type' landscape:

> [@Improving the UI of generics](https://forums.swift.org/t/improving-the-ui-of-generics/22814):
>
> @Douglas_Gregor wrote the [Generics Manifesto](https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md) almost three years ago, which provided the roadmap for the core of Swift's protocols and generics features. Since then, we've implemented almost all of the basic model that it envisioned. Although there are further features we could add, we think we have a solid baseline; meanwhile, we've gained practical experience with the model in developing the standard library, we've absorbed lots of feedback from the larger Swift development community, and we've…

In short we have:

- `Kraken` as a protocol
- `Kraken` as a protocol type - existential, which eventually might become `any Kraken`
- there is also potentially a `some Kraken` which is the opaque result type (also called reversed generics by others) that allows you to hide the concrete type for your user, but not from the compiler so that you can use that type in generic context.

There is a lot more to cover but I don't want overwhelm you with all that information. I do recommend you to read the official Swift book if you haven't already, it definitely covers the most essential part of these things.

---

_[View the full topic](https://forums.swift.org/t/protocol-conformance-for-protocols-with-var-myvar-mytype-get/30745)._
