In C my favorite way of achieving encapsulation is to use incomplete types. The module header contains the definition of an incomplete type and the prototypes for the public functions which operate on it. I have read D has incomplete types too however D does not have headers and as a C guy I do not know how to implement this scheme without a .h/.c separation.

As I said, in C I put the incomplete declaration in the header while keeping the complete declaration private to the module. How do I do this in D? I mean type is complete within the module itself (and thus can be instantiated there) but incomplete for clients (i.e. other modules) i.e. instantiating or modifying data of that type directly is impossible.

P.S.: It seems D lingo for incomplete types is "opaque types".

Reply via email to