Introduce Any<P> as a better way of writing existentials

Reading an older post on a related topic I had another idea for a possible spelling in lieu of using the any P spelling. As Dave illustrates in the linked post, an existential is only as much of its protocol’s API as possible to be “the most specific possible common supertype of all types conforming to the protocol.”

With this in mind, I think a more precise spelling would be as partial P to communicate that the existential type only encompasses the part of the protocol that can be common to all conforming types (I think for some protocols, that could be all of them, making the partial P name seem awkward in those instances). Additionally, any extension extending functionality to a partial P for which the compiler can determine has no accessible API, like the P in Dave’s example, should generate a warning.

1 Like