Dynamic D Library
teo
teo.ubuntu at yahoo.com
Wed Jul 15 23:12:47 PDT 2009
One major problem is the D's inability to create dynamic libraries. D is a great language, but without that ability it can only be used for small programs, tools, etc. and never in production.
The D Runtime is a step forward, because it faces that problem. I noticed following:
extern (C) void* rt_loadLibrary( in char[] name );
extern (C) bool rt_unloadLibrary( void* ptr );
/**
* Locates a dynamic library with the supplied library name and dynamically
* loads it into the caller's address space. If the library contains a D
* runtime it will be integrated with the current runtime.
*
* Params:
* name = The name of the dynamic library to load.
*
* Returns:
* A reference to the library or null on error.
*/
static void* loadLibrary( in char[] name )
{
return rt_loadLibrary( name );
}
/**
* Unloads the dynamic library referenced by p. If this library contains a
* D runtime then any necessary finalization or cleanup of that runtime
* will be performed.
*
* Params:
* p = A reference to the library to unload.
*/
static bool unloadLibrary( void* p )
{
return rt_unloadLibrary( p );
}
However If the library contains a D
runtime it will be integrated with the current runtime.
Is this really needed? If the intention is to replace C/C++ some day, why not just provide a dynamic D library? (like in this project: http://www.dsource.org/projects/ddl/) It can contain only compiled D code accompanied with meta-data like platform, version, etc. and be used only by D programs. No runtime is needed within the DDL. When the DDL is loaded it will be managed by the same GC which manages the program itself. Even Phobos can be a DDL.
Maybe I am missing something and that's why I would like to hear your opinion.
More information about the Digitalmars-d
mailing list