Enhancement request
grauzone
none at example.net
Thu Jul 9 11:20:19 PDT 2009
Hey Robert, so how do I get all methods of a type? This doesn't work in D1.
> Now suppose that get() is somewhere in a library that isn't aware of object Person and of a template. Because that is the problem with libraries and especially DLL's. It needs to be more dynamic. Theoretically, it should be possible to extract everything out of Person without knowing any of the particular behavior of that class. So accessing fields, writing to fields, etc. should be possible with such libraries.
You still could write your own reflection library on top of tupleof. The
only problem is, that you need to make all members known to that
reflection library, before you can access them from any runtime context.
For example, you could pass all types to a compile time function of your
reflection library:
Reflection.register!(Person);
This call would instantiate template code to grab all members of Person
using tupleof. That code would produce your own extended RTTI about the
passed type. Then the library can map TypeInfo or ClassInfo to that
extended RTTI type. You could get the RTTI information even from a DLL
(as long as the runtime is shared between the DLL and the host code.)
The problem is, that you have to litter your code with calls like above.
Even with D2's glorious __traits, this problem persist: you have to pass
all types manually to some piece of compile time code.
Now, dear D Gods, how are we supposed to solve this problem? Could we
(at least) get a way to list all members of a module with __traits?
(Wow, a function crawling all modules recursively at compile time sure
would produce a lot of template bloat.)
More information about the Digitalmars-d
mailing list