DDL 1.2 Beta
Pragma
ericanderton at yahoo.removeme.com
Thu Sep 7 09:58:22 PDT 2006
Craig Black wrote:
> Nice work! Does DDL do dynamic class loading?
>
> -Craig
>
>
Yes, but not in the Java sense of the word - at least not yet. ;)
At the moment, DDL operates that the module/library level. Once you
have that loaded (.obj, .lib, .o, or what have you) and linked, then you
interrogate it for what symbols it provides. So it's operating a
slightly lower level than we'd prefer. However, this is a level at
which Java is clear as mud, so I'd like to think that this approach is
much more modifiable and extensible.
In the case of finding class information, you can use the template
methods exposed on the DynamicLibrary class to find a particular ctor or
ClassInfo, or use the ExportClass template for a more well-honed approach.
I'll take the opportunity here to note one other important difference
between Java and D/DDL. Due to D's design as a statically compiled
language, one cannot achieve lazy class loading at every call to 'new'.
Instead, every external reference that a given module has, must be
resolved during a link pass before that library can be safely used.
In essence: The same drawbacks that exist at "compile-and-link time" are
the same as at "run-and-link time".
Anyway, the Linker class helps with the above - any call to a link()
method will result in an Exception if the library in question cannot be
fully resolved.
--
- EricAnderton at yahoo
More information about the Digitalmars-d-announce
mailing list