Dynamic loading, D all the way (dmd 64bit 2.060/Ubuntu 64bit 12.04/x86_64)
Philip Daniels
foo at foo.com
Thu Aug 23 15:26:24 PDT 2012
On Wednesday, 22 August 2012 at 16:57:26 UTC, Paulo Pinto wrote:
> On Wednesday, 22 August 2012 at 15:51:05 UTC, Philip Daniels
> wrote:
>>>snip<
>>
>> If we had dynamic loading, would we be able to do dependency
>> injection in D?
>
> Dependency injection does not require dynamic loading per se.
>
> It is all about using interfaces instead of classes, and
> initializing the corresponding instance members.
>
> You just need some piece of code that takes the responsibility
> of locating such interfaces, by registering the classes
> somehow, or by compile time reflection, which gets called on
> program initialization.
>
> You can do this in D today.
>
> --
> Paulo
But wouldn't that require you to link everything together at,
err, compile time?
What I'm getting at is, would it be possible to port a DI/IoC
tool such as StructureMap
(http://docs.structuremap.net/index.html) or Spring to D? This
can handle tasks such as creating dynamic plug-in architectures.
For example, given SomeBigApp.exe (not written by me) which looks
in standard folders for components implementing a particular
interface, I can just drop my code in that folder and have it
loaded at runtime. I could even drop it in there after the
program starts running. I know how to achieve this in the .Net
world, just wondered if it was possible in D.
More information about the Digitalmars-d
mailing list