This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [c++, cxx-reflection] Initial thoughts on type reflection.


> | > 1. primary-expressions
> | > 
> | >     That means that you then need to worry about things like   
> | >     "&magic_foo", and "magic_foo((int))".
> | 
> | I don't think that's what Gaby had in mind.  (Gaby?)
> 
> You're right.  Actualy, the above sjhoudl read "postfix-expression",
> not "primary-expression". 

Every primary-expression is a postfix-expression; that is the only use
of primary-expression in the grammar.  "magic_foo (3)" might be
postfix-expression, but "magic_foo" by itself could be a
primary-expression.  I don't think that makes sense, which was my point;
you want to avoid "magic_foo" by itself being a complete expression. 
Instead, "magic_foo" should only be legal if followed by arguments.

You could do that either via introducing new analogues to typeid, or new
analogues to sizeof.

> What I'm proposing is to generalize the syntax
> 
>         postfix-expression ( expression-list_opt )
> 
> to allow "type-id"s in the expression-list.

This is both complicated and unncessary.

These new magic things are keywords, not functions.  They are like
typeid or sizeof, not like sin or strcmp.

In the past, you've argued against this for "scalability".  But that's a
red herring; you can easily have a table of codes corresponding to the
new operators and make a REFLECTION_EXPR to handle all of these
expressions.

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]