I'm pleased to announced that the Language Workgroup has accepted its first vision document, entitled Using Swift from C++:
This vision document presents a high level overview of the "reverse" (i.e. Swift-to-C++) half of the C++ interoperability Swift language feature. It highlights the key principles and goals that determine how Swift APIs are exposed to C++ users. It also outlines the evolution process for this feature. This document does not present the final design for how Swift APIs get mapped to C++ language constructs. The final design of this feature will evolve as this feature goes through the Swift evolution process. This document does not cover the "forward" (i.e. using C++ APIs from Swift) aspect of the C++ interoperability, as it’s covered by a sibling document.
As discussed in my general post about vision documents, the Language Workgroup's acceptance of this document is a strong endorsement of the goals laid out in the vision, a general endorsement of the basic approach, but only a weak endorsement of any concrete proposals. All proposals in the vision will have to undergo ordinary evolution review, which may result in rejection or major revision.
Please feel free to discuss this vision in this thread.
Since one of the goals of this work is to enable C++ developers to integrate Swift code, I hope we also make a point of reaching out to some C++ developer communities when concrete proposals are ready, so we can invite them to also participate in the process. The users available to review proposals here on the official Swift forums are likely to be more recently familiar with Swift than C++.
It can also serve to raise awareness that this work is happening. Some developers may be curious to see how their APIs get imported by Swift, and hopefully they'll be impressed by what they see.
Depends what you mean by first version, but we’ve been using cpp interop actively using nightly tool chains in a fairly complex c++ project already for a while. Worth trying out what already is there today
I have read the vision document and a little of implementation.
It is a smart design to have C++ compiler support Swift's calling convention so that it can export to C++ without any opt-in work like @objc.
Attributes like swiftcall and swift_context are ultimately handled by LLVM, so the clang changes seem relatively lightweight.
But how will you support GCC, Visual Studio, and the many other C++ compilers?
Are there any plans to do?
Yes, you can already call swift form c++. Many situations already work, though still there’s missing things here and there, mostly around things that touch templates or move only types or other advanced c++. But basic things work just fine—basic reference or value types etc.
This is a vision document laying out the work that makes that happen. Significant amounts of it have already been prototyped. That work will be broken down into proposals and reviewed over the coming months.