Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2006-02-03 21:12:36

David Abrahams wrote:
> Edward Diener <eddielee_at_[hidden]> writes:
>> I think it is a commendable goal in Reflex to be able to reflect the
>> parameter types for any given template instantiation, since this
>> information may be valuable and usable at run-time. After all, at
>> run-time, information about a template type should be just as accesible
>> regarding finding type information than any other type. One of the
>> pieces of information about a template type is the parameter types which
>> are used to instantiate the template, so run-time reflection should
>> include such information. But I feel that information about the template
>> declaration/definition itself belongs in the realm of a compile-time
>> reflection system, not a run-time reflection system, and can serve no
>> purpose in a run-time reflection system.
> Even if the run-time reflection system is generating code?
> The boundaries are a lot more fluid than you probably imagine.

I do not doubt that a compile-time reflection mechanism would be
invaluable to template programming at compile time, but I do not see how
such a reflection mechanism can work there unless it were integrated
into the language/compiler itself since the benefits of a compile-time
reflection mechanism would be to manipulate template code at compile
time, similar to the way MPL does but with more built-in langauge
functionality. I do not say that such an integration is not a worthy
project, and to be considered as an addition to the C++ language, but I
would rather separate compile-time reflection and run-time reflection
since the latter can work without changing the language/compiler, as
Reflex shows, while the former appears to me to need such a change. So I
think it would be worthy to approach the easier task first, under the
aegis of run-time functionality rather than the harder, and not mix the
two in an initial attempt to provide C++ reflection.

At the same time, regarding run-time reflection, and given the fact that
Reflex can reflect directly from a type or an object, I would still love
to see, if C++ adapts such an approach to run-time reflection, an
equivalent to the built-in "typeid" operator, eg. maybe
"reflection_typeid" or maybe "extended_typeid" or maybe just "typeid"
generating a full reflection type ala Reflex, as part of the C++
language. But barring that, using the specific classes of Reflex at
run-time works also. I just think the built-in operator way of doing it
would be more elegant and more in keeping with the "typeid" idea, and
the feeling that run-time reflection is part of the language.

Boost list run by bdawes at, gregod at, cpdaniel at, john at