SE-0244: Opaque Result Types

I've mostly stayed out of this thread, but this is exactly my concern. Swift has gone out of its way to have declarations for types (structural types excepted), which is important to the linkage and compilation model, but also the diagnostic and user model. Specifically, it is very problematic to me that these types cannot be named in a natural way, but their identity matters. This is what makes them different than structural types.

I think this approach would be far better: "Opaque type aliases" as a feature seems like it would solve exactly the same set of problems (and the type aliases can have generic constraints already etc) but would provide a name and identity for the type that can be used across declarations within client code. Also, the "future directions" in this proposal seem like they will add a significant amount of language complexity when/if they happened, whereas they would naturally fall out of opaque type aliases.

I'd strongly +1 that direction over the proposal as is.

-Chris

23 Likes