3 ms·
For now i think you can just wrap it all up in C headers, and implement them in C++, calling the right API. But giving the way the Swift compiler is itself wri
by oscargrouch 9y ago
For now i think you can just wrap it all up in C headers, and implement them in C++, calling the right API.
But giving the way the Swift compiler is itself written in C++ and tied to the LLVM, i bet it will be "easy" for the Swift compiler team to create interoperability between C++ and Swift.
I think their current goal with ABI compability is one step in that direction.. so it will be just a question of Swift understanding C++ mangling in elf/coff/mach-o objects for the link time, and interpret C++ headers using Clang for the compile time.
Given all that, is not hard to predict that Swift will probably have the best interop with C++ code than any other language out there.
- quux 9y agoThe swift compiler being written in C++ has nothing to do with how swift calls into C++ code.
- oscargrouch 9y agoTheres a first part of my comment where i talk about ABI, name mangling, etc.. a goal Swift 4 is achieving, and i bet the possibility to reference C++ linked symbols will be there eventually, giving the project is very tied to LLVM and Clang. Then there's a second part where i comment about the ability to parse C++ header using Clang when parsing Swift code, so you can get this in compile time. (You probably noted this part and lost some of the information that i've implied from the first). So, i didnt imply that it was because the Swift compiler was written in C++ that it would have these properties, but because of its history of being tied together with LLVM and Clang, being coded by the same people behind LLVM and Clang. I hope it gets more clear what i've meant to imply with my comment now.