Does D have reflection?

Adam D. Ruppe destructionator at gmail.com
Sat Apr 5 19:28:11 PDT 2014


On Sunday, 6 April 2014 at 02:25:32 UTC, dnspies wrote:
> For instance, could I write a generic function to reconstruct 
> any object of any type from a JSON object?

Yes, you can use __traits(allMembers) at compile time to build a 
runtime function that does the setting. .tupleof can do it too, 
which is what I used in the fromUrlParam function in my web.d 
that populates a struct from an associative array of runtime 
strings:
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/web.d#L2507


More information about the Digitalmars-d-learn mailing list