dub: how to reference a compiled package

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 25 22:36:02 PST 2016


On Friday, 26 February 2016 at 03:19:26 UTC, mahdi wrote:

> Great! Thanks.
>
> I was looking for a feature like `jar` files in Java or 
> `assemblies` in C# where all compiled code and metadata/symbols 
> are stored together inside a single binary file.
>
> I think same can be implemented for D language and it won't 
> break any code because it is not touching the language itself, 
> but the compiler.

The magic in Java isn't from Jar files, but from the fact that 
class binaries are distributed as byte code. All of the 
information from the source is still there. The compiler can 
learn everything it needs to know about imported classes simply 
by reading the byte code instead of the source.

In the model that D uses, I don't know enough about object file 
formats to know how much information would still be available if 
they were used at compile time, but I'm fairly certain it 
wouldn't allow the use of templates. There was a project several 
years ago that allowed loading D classes dynamically from object 
files, but I suspect if it were practical to use object files at 
compile time in the same way Java class files are used, someone 
would have implemented such a thing already (in C and C++ as 
well).

That said, it might be an interesting enhancement for the 
compiler to support reading source or interface files from zip 
archives (which is I know is what you're getting at), allowing 
the required imports and the binary to be located in one place so 
that only a single path need be passed on the command line to 
find everything.


More information about the Digitalmars-d-learn mailing list