How to store a pointer to class contructor

Dmitriy Asondo dmitriy.asondo at gmail.com
Thu Dec 24 10:23:09 UTC 2020


Hi!

You may hate me, but currently I'm using nodejs. I want to use 
dlang as a second instrument and I'm trying to check some js-like 
features. For example, if I want to store somewhere in 
array|tuple a list of pointers to classes (app services) how may 
I do that?

I expect code like this:
----------------------
class OloloService {}
class BlablaService {}

auto servicesList = [OloloService, BlablaService];
auto serviceInstance = new servicesList[1](args);
----------------------


But such costructions is impossible in D, so, may be anybody may 
explain how to organize app "services" and what ways of 
dependency injection exist for D?

Thank you :)


More information about the Digitalmars-d-learn mailing list