Some Thoughts on C++ Interoperability

     Splitting this out from '[Manifesto] Interoperability between Swift and C++' under 'Discussion' under 'Evolution' and cross-posting it from this post on that thread after it didn't get noticed:

      Rather belatedly, here are some things I thought might — well? — need to get taken into account, kept in mind, and/or tracked, at least at some point, sorted roughly by the section(s) of the manifesto they pertain to:

  • 'Differences in move semantics between C++ and Swift' and related sections:
    • Recent attempts to propose 'move relocation' for C++:
      • P1029 , move = bitcopies (previously move = relocates, née SG14 [[move_relocates]]) by Niall Douglas (GitHub tracking issue at cplusplus/papers#359)
      • P1144 , Object relocation in terms of move plus destroy by Arthur O'Dwyer (GitHub tracking issue at cplusplus/papers#43)
  • 'Templates :'
    • Could the problems here get mitigated (on the C++ side) by, for each unspecialized template, using a type-erasing polymorphic wrapper to implement a handle bundling all of the concrete instantiations of that same unspecialized template's defaulted or custom, explicit or implicit specializations together?
  • 'Exceptions :'
    • Standards proposals for introducing 'static exceptions' into C++, as well as one other, related paper:
      • P0709 , Zero-overhead deterministic exceptions: Throwing values by Herb Sutter (GitHub tracking issue at cplusplus/papers#310 )
      • P1028, SG14 status_code and standard error object (previously SG14 status_code and standard error object for P0709 Zero-overhead deterministic exceptions,) by Niall Douglas (GitHub tracking issue at cplusplus/papers#405)
      • P1095R0 (also ISO C WG14 N2289,) P1095R0/N2289: Zero overhead deterministic failure — A unified mechanism for C and C++ by Niall Douglas (GitHub tracking issue at cplusplus/papers#319 )
      • P2170, Feedback on implementing the proposed std::error type by Charles Salvia (GitHub tracking issue at cplusplus/papers#879)
      • Maaay-be P2232, Zero-Overhead Deterministic Exceptions: Catching Values by Emil Dotchevski (GitHub tracking issue at cplusplus/papers#965)

Also, when it comes to text handling, there might be some additional work WG21's SG16 for text and Unicode could do on the C++ side to make things easier for interoperating with Swift and other languages which you could coordinate with them.

Finally, also, could type-erasing polymorphic wrappers on the C++ side also help with protocols? (In the sense — or sense adjacent to — 'run-time concepts' and P1900, namely sections 3.1 and 5, though of course nothing's come of that/those line(s) of thought in terms of WG21 standards proposals just yet.)