dpp icon indicating copy to clipboard operation
dpp copied to clipboard

Possibility to treat type as an opaque blob?

Open Laeeth opened this issue 5 years ago • 1 comments

https://rust-lang-nursery.github.io/rust-bindgen/opaque.html Example where this would be useful - Xenon uses STL types as member variables of classes but they are all private. And either the methods don't need STL types or it is possible to add overloads that will take a Cpp version of a D-friendly type (slice for vector, something sensible for map). Or of course could have factory functions for the relatively few specialisations of STL types we actually use. This makes it much easier for D code to eat away at the C++ with working code all the way through.

Laeeth avatar Aug 05 '18 19:08 Laeeth

I think that this would make it much quicker to be able to use real C++ APIs. Often the barrier is the STL or Boost types. They might even be private and it's easy to add a function on both sides if you only need part of the API and want to call a method taking vector for example. But as things stand you need to be able to cover the relevant parts of STL, Boost or whatever just to be able to represent the types on the D side. So it makes the problem easier to have working useful code along the way if there is an escape hatch of opaque types.

Laeeth avatar Aug 19 '18 23:08 Laeeth