Chances of D getting proper runtime reflection?

bearophile bearophileHUGS at lycos.com
Sun Aug 21 04:41:38 PDT 2011


Jacob Carlborg:

> class Foo
> {
>      private int a;
> 
>      private void bar (int i)
>      {
>          a = i;
>      }
> }
> 
> auto foo = new Foo;
> Object o = foo;
> o.setInstanceVariable("a", 3);
> assert(foo.a == 3);

Is this related to the Delphi feature I've recently shown?
http://blog.barrkel.com/2010/09/virtual-method-interception.html

I presume you will have to write:

@reflection class Foo
{
    private int a;
...

To be sure to not pay for this dictionary when you don't need it. In theory this annotation is unnecessary.

Bye,
bearophile


More information about the Digitalmars-d mailing list