Making plugin system with shared libraries. Upcast in shared lib

MrSmith via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 20 11:29:42 PDT 2014


On Monday, 20 October 2014 at 15:30:28 UTC, Martin Nowak wrote:
> On 10/20/2014 12:32 AM, MrSmith wrote:
>> Than any module can search for registered modules and try to 
>> cast them
>> to concrete type (upcast).
>
> That can't work because the notion of types only exists during 
> compilation. Therefor it's not possible to load new types at 
> runtime and use them in code that was compiled without knowing 
> those types.
> You should simply use interfaces to achieve your goal.

In this case ether shared lib knows actual type.

But i've tried it with interfaces, (upcast also), or do you mean 
something else?

1) I want application to load IModule from .so/.dll
2) Any other module should be able to cast that IModule to actual 
type (upcast) and test if result is !null.
3) Can i do this using interfaces or without them? I.e. if in 
first example module2 is interface


More information about the Digitalmars-d-learn mailing list