D and reflection

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Wed May 7 09:59:57 PDT 2014


On Wednesday, 7 May 2014 at 16:51:10 UTC, amehat wrote:
> Hello everyone,
>
> I'm working on porting a java library in D, and I stuck on a 
> class because it works with the reflection.
>
> From what I've read on prowiki 
> (http://www.prowiki.org/wiki4d/wiki.cgi?LanguagesVersusD), D 
> can not do reflection, it is limited to the Run-Time Type 
> Information (RTTI ) (http://dlang.org/traits.html).
>
> Here is the piece of code that blocks me:
>
> static {
>         Class clazz = this.class;
>
>         auto accessible2Args = new Callback(clazz, 
> "accessibleProc", 2);
>         auto proc2Args = accessible2Args.getAddress();
>         if (proc2Args === 0) {
> 		(...)
> 	}
> (...)
> }
>
> I am looking for a workaround that I have not found yet.
> If someone an idea on the subject, I'm interested.
>
> Thank you to you.

Firstly, the the wiki has moved: wiki.dlang.org

D is very powerful at compile-time reflection, but less powerful 
at runtime. I'm afraid I don't quite understand what you need in 
your example.

http://forum.dlang.org/group/digitalmars.D.learn would be a more 
appropriate place for your question.


More information about the Digitalmars-d mailing list