Scope of D packages
cym13 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Dec 18 17:18:35 PST 2015
On Saturday, 19 December 2015 at 00:52:40 UTC, Jakob Jenkov 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.
> But - if the library was open source, it would be better to
> just share the sources than a compiled file? (In Java we
> share/use the zipped JAR file with compiled classes).
If it's open source it's better to share the sources, sure. As
the compiler is able to do more optimization when it has all the
sources at hand it is customary to limit the use of shared
libraries and just compile everything at once (although you can
quickly run into things like memory limitations as it demands
quite a lot of resources). Typically you'd segment your
compilation by module if needed.
If you are to give the sources (with or without a standalone lib)
then you allow your users to benefit from such optimizations if
they want to, so it's better to give the sources when possible. D
Interface files are there mostly (only?) to answer the
problematic of closed source libraries.
More information about the Digitalmars-d-learn