Rainer Deyke wrote:
My first impression of Describe is that it looks very useful. However, there are two things that bother me.
1. There appears to be no way to add annotations to members. I often have class data members that should be excluded from serialization.
We all do. :-) I want to keep alive the dream of having this in the core language one day, which implies that ideally we'd spell that struct X { int m1 [[transient]]; // do not serialize int m2 [[version(4)]]; // only in v4 or later }; and then have a way to get these attributes in the member descriptor. I'll try to figure out a way to provide this in the library in a way that would be compatible with language attributes.
Without annotation support, I would have to maintain my own external list of such members in order to use automated serialization.
2. The examples are powerful, but they're also kind of complicated and ugly. I can't help thinking that it might be possible to simplify the client code by moving more code into the library. For example, describe_enumerators_as_array seems like a useful addition to the library.
This specific one does, yes. But in general, each use typically is slightly different. Enum to string conversion, for example, can fail in both directions, and there's no one right way to handle these failures. It's just easier to write your own enum_from/to_string which work exactly as you want them to work. And for things like JSON, hashing, serialization, the goal isn't for the Describe library to provide the functionality; the goal is for it to serve as the standard way for these other libraries to be able to query the member descriptors and automatically provide behavior out of the box. Of course if some piece of functionality is reinvented verbatim, over and over, it will (eventually) get added to the base library. Just not today.