Runtime introspection, or how to get class members at runtime Fin D

evilrat evilrat666 at gmail.com
Thu Jun 7 13:07:21 UTC 2018


On Thursday, 7 June 2018 at 12:32:26 UTC, Arafel wrote:
> Thanks for all the answers!
>
> Is it possible to register, say, a base class, and have all the 
> subclasses then registered automatically?
>
> My idea would be to make it as transparent as possible for the 
> plugin implementation, and also not having to depend on it.
>
> A.
>

I don't think so. It clearly states that children must mixin too, 
which can mean it just grabs symbols in scope only, and base 
class has no way of knowing about its subclasses. It also has 
"agressive mode" that will make metadata for all public 
symbols(?) it can walk, this may or may not be helpful depending 
on your requirements.

Besides there is no way(not that I am aware of) to make self 
registering stuff happen, you still need to call it somewhere. 
The most transparent option is probably just doing a mixin in 
each module that performs registration of all module symbols in 
module ctor.
The point is that there is absolute requirement to make explicit 
call for that, be it a module ctor mixin, class mixin or even 
user provided registration both at compile time or run time.
But since it is MIT licensed you can probably use the code as the 
starting point and adjust to your own needs.



BTW plug-ins is something that is right now possible on Linux(not 
sure about support on other *NIX systems), but in a very 
primitive form on Windows.
This is related to DLL support issues(such as type information 
not being passed across process/DLL boundaries), these issues 
also may include runtime issues as well such as inability to 
delegate the GC, which will mean there will be 2(or more) 
concurrent running GC's. But again I am not aware of the current 
situation.


More information about the Digitalmars-d-learn mailing list