[Pitch] Primary Associated Types in the Standard Library

I 100% get this, but on the other hand, this is an inherent trade off in this feature -- we don't have labels for things within angle brackets, so it isn't at all obvious what Int means in MyProtocol<Int> or MyGenericStruct<Int>. To understand these, I have to go look at the declaration/documentation of the protocol/struct.

(Incidentally, the first cut of SE-0346 highlighted that we don't have a formal way to add API docs for type parameters of a generic type or generic function.)

If we were to take this objection seriously, then that would effectively mean that SE-0346 will be strictly limited to Sequence-style container protocols. Then again, I'm sure even Collection<Int> will confuse somebody: is it providing a collection interface to access individual bits in an integer?

My impression from reading the Core Team's verdict is that this is intended to be a general-purpose alternative to the classic generic declaration syntax, not some niche feature that is dedicated to sequences.

2 Likes