Introspection/Reflection/etc on Linux

Robert Jacques sandford at jhu.edu
Tue Oct 18 20:13:26 PDT 2011


On Tue, 18 Oct 2011 12:48:47 -0400, J Arrizza <cppgent0 at gmail.com> wrote:

> I'm trying to write some sample code to:
>   1 create an object via it's name
>   2 search an object for it's functions
>   3 call a static function in a class
>   4 call a non-static function in an object
>
> #1, #2 and #3 were straightforward. But  #4 looks like it's not possible in
> DMD 2.0.
>
> I found this:
>
> http://www.digitalmars.com/d/archives/digitalmars/D/announce/Runtime_reflection_9949.html
>
> which implies #4 is doable in Windows but not Linux. I'm using Linux 64-bit
> Ubuntu.
>
> Any other avenues I can chase?
>
> TIA,
> John
>

You could try out my improved variant implementation:

https://jshare.johnshopkins.edu/rjacque2/public_html/variant.mht

https://jshare.johnshopkins.edu/rjacque2/public_html/variant.d

Example:

import variant;

class Foo { int x; }
void main(string[] args) {
     Variant.__register!Foo;
     Variant var = Object.factory( typeid(Foo).toString );
     var.__reflect("x",Variant(10)); // or explicitly
     assert(var.__reflect("x") == 10);
     return;
}


More information about the Digitalmars-d mailing list