On 06/06/2018 03:30 PM, rikki cattermole wrote:
You don't want TypeInfo.

Why not (genuine question)? There's even myObject.classinfo, and I can only assume that there's some reason why it's there...


In this case, what I'm trying to do is to serialize / dump / print the contents of an object (class instance) without knowing its actual runtime type.

Before somebody suggests compile time introspection, the "main" code where this routine lives only provides a base class, and it's up to dlopen'ed plugins to provide the actual implementation... so I'm sorry but no compile-time solution can possibly work.

Also, having each derivative class provide their own dumping information is not practical, I'd rather have it automated.

I know it might not be the most idiomatic D, but as somebody with mostly a Java background (with some C and just a bit of C++) it seems something really straightforward to me: myObject.getClass().getFields() [2].

Doesn't exist.



Well, thanks for the quick and succinct answer... I guess the question now would be how realistic it would be to propose such an addition to the language... Has it already been discussed? (I tried searching the forum, but didn't find anything relevant)

I know it's got a runtime penalty, but realistically speaking, spending some bytes for the field names in the TypeInfo of a class shouldn't be that much of a problem?

Reply via email to