This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [c++, cxx-reflection] Initial thoughts on type reflection.
> Whether you call it "operator" or built-in that takes a type-id does
> not change anything fundamental at all.
What are these new magic_foo things, in terms of the existing grammar?
1. primary-expressions
That means that you then need to worry about things like
"&magic_foo", and "magic_foo((int))".
2. Operators, ala sizeof.
Strongly suggest the second answer. (Why? Because everything will just
work in that case. You don't have to deal with things like "&foo".
Using these operators inside templates will work correctly, if you
introduce something analagous to SIZEOF_EXPR. You can reuse things like
cp_parser_sizeof_operand to handle the parsing and semantic processing.)
Frankly, you'll have a hard time getting me to agree to anything else.
There is no reason this has to get messy; you just create a table of the
operators, and voila, you're done.
Thinking about these things as builtin functions is not right;
functions, in C++, do not take types as arguments. These things are
operators on types.
--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com