On Wed, 18 Dec 2002, Yitzhak Sapir wrote: > I think it is possible to implement a reflection framework using the > preprocessor library. In much the same way that one of the links > previously mentioned > ( http://www.garret.ru/~knizhnik/cppreflection/docs/reflect.html ), a > description system could be made. The difference is that unlike the > example definition of the above link:
<snip> > We would have something more like the following: > > #define A_DESCRIPTION DESCRIBE_STRUCT(6, \ > (RTTI_(int, i, RTTI_FLD_PUBLIC), \ > RTTI_(char*, pc, RTTI_FLD_PUBLIC), \ > RTTI_(double, d, RTTI_FLD_PUBLIC), \ > RTTI_ARRAY(long, 10, larr, RTTI_FLD_PROTECTED), \ > RTTI_(A**, ppa, RTTI_FLD_PROTECTED), \ > RTTI_(A*, pa, RTTI_FLD_PROTECTED))); > > class A > { > IMPLEMENT_DESCRIPTION(A_DESCRIPTION); > int x; // some member variable which is not described > }; > > This has the advantage that you don't to respecify everything twice, and > yet, most of the serialization functions could be generated automatically > from A_DESCRIPTION. I agree. I don't like redundant data. We could provide a macro interface as well as provide tools to automagically generate the metadata. A macro interface could also be useful to customize the fields, as Jeremy Maitin-Shephard mentioned (but so could source-to-source translation tools). However, IMHO, using the PP is much more difficult to program, debug, and maintain. It's also less powerful than having access to the IL (eg: how will this handle free functions and namespaces? how could it support existing code bases?). We could keep it around as a lowest common denominator option tho. --craig _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost