Excuse me for thinking aloud, if I mayâŠ
The proposal introduces a new keyword. It has often been mentioned that scattering the language up with too many keywords is not a good idea. What if we introduce something like a placeholder type, which from the outside would more look like a 'concrete' type.
func foo() -> opaque Collection where _.Element: Hashable {}
could become something like
func foo() -> Opaque<Collection where _.Element: Hashable> {}
I think this would also immediately solve the question raised upthread whether opaque P & opaque Q
could be allowed. No.
Thinking further. Would Opaque<>
or Qpaque<_>
then be allowed? Basically it would mean nothing more than Any
, any type without any constraints. If so, why not call the opaque placeholder type Any
in the first place?
The above could become
func foo() -> Any<Collection where _.Element: Hashable> {}
There was concern about using the underscore to refering to the type itself, instead of the omission of something. This probably could be solved with what we're doing elswhere in a generic context:
func foo() -> Any<T: Collection where T.Element: Hashable> {}
or
func foo() -> Any<This: Collection where This.Element: Hashable> {}
Lots of room for bikeshedding left⊠;-)
I could imagine that this approach could also simplify the question what type(of:)
should give back.
Excuse me for an amateur thinking aloud. I hope I'm not completely off the trackâŠ