How to store a pointer to class contructor

Jacob Shtokolov jacob.100205 at gmail.com
Thu Dec 24 14:28:11 UTC 2020


On Thursday, 24 December 2020 at 10:23:09 UTC, Dmitriy Asondo 
wrote:
> Hi!
>
> 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?

Hi, it seems that what you're looking for is Prototype 
Inheritance, which is not quite common among staticly typed 
programming languages due to its runtime nature.

Please note that the way you've implemented it in JavaScript 
doesn't take compile-time class constructors into consideration. 
Just look at how you're passing constructor parameters to your 
objects. In D, each class may have its own constructor, so the 
arguments may be totally different.

Also, it looks like you're trying to implement some kind of a 
Service Locator.

Could you tell what are you trying to achieve with this code? Are 
the arguments and the array index received at runtime?


More information about the Digitalmars-d-learn mailing list