Scope of D packages

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 19 11:35:16 PST 2015


On Saturday, December 19, 2015 17:09:49 Enamex via Digitalmars-d-learn wrote:
> On Saturday, 19 December 2015 at 00:46:12 UTC, cym13 wrote:
> > To be exact it doesn't need the sources, it needs the function
> > signatures and type definitions so the equivalent of C header
> > files. If you don't want to share the full sources with your
> > library you can generate those header files automatically using
> > the -H flag in dmd. It will produce a "D interface" file with a
> > "di" extension.
>
> How does this interact with templates and introspective code?

Templates must always have their entire source available (even in .di
files), and any function that you want to be inlined or to use with CTFE
must have its entire source available. Also, any functions involving auto in
their signature will have to have their full source available.  However, at
the moment, I can't think of any compile time introspection which isn't
going to work with just the signatures, because that's all that that stuff
looks at anyway.

In general, I would strongly argue that unless you _need_ to hide your
source code, you should not use .di files, and given how heavily a lot of D
code uses templates, a large portion of the D code out there _can't_ hide
its source code. As I understand it, .di files are there primarily for the
corporate folks who insist on hiding their source, since some companies
would refuse to use a language that did not allow them to hide their source
code.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list