proposals: propose protocol metatype extensions#3244
Conversation
61a8319 to
af9f0a3
Compare
|
|
||
| We consider this a natural future direction but out of scope for this proposal. | ||
|
|
||
| ### Protocol metatype conformances |
There was a problem hiding this comment.
We discussed this proposal in the Language Steering Group this week. One of the questions we had was whether this proposal was a complete enough story to do what folks might want to do with things like COM interop (or even non-COM use cases). This would be adding a capability to the language where we can use the protocol as a namespace, but as currently written, it ends there—it doesn't permit the kind of generic programming that a user might otherwise expect.
This section points out that a natural thing to want to do with these extensions would be to pass the metatype to a generic function that would operate on that IID. And without the ability to conform metatypes to protocols, there's no way to express that today:
func someFunc<T: /* ??? */>(_ comInterface: T) {
let iid = T.IID
/* do something with iid */
}
someFunc(IDispatch.self)Is this something you foresee users of COM interop wanting to do, and if so, does it follow naturally from what is being proposed here? Did you have plans to work on this space as well, or is this more of an open question?
There was a problem hiding this comment.
Yeah, this is something that I could see as being valuable (and eventually needed). I think that that this would be something to revisit in the future once more of the COM infrastructure is built out. But, yes, I do feel like it would flow from this work. As to the work itself, that would be more of an open question and something that would come back up when the WinRT layer starts getting looked at.
|
The Language Steering Group discussed this last week and we think there are some unanswered design questions that need to be figured out before this can be run. The main concern surrounded the inability to operate on metatypes generically. Even though you acknowledge this as a future direction, we want to avoid backing ourselves into a language design corner if we allow folks to inject members with the current "namespace" approach, especially around the choice that For the COM interop use cases you had in mind like generating IIDs for interface protocols, we were generally more comfortable with just having those be synthesized via compiler magic for the time being, rather than add a metatype feature that isn't fully realized. |
Propose protocol metatype extensions