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.


Phil Edwards <phil at jaj dot com> writes:

> Gaby and I have been discussing this in private, on and off, for a few weeks.
> I've made 3 or 4 implementations with varying tradeoffs.  Even though the
> cxx-reflection-branch is experimental, it would nice to get some public
> discussion before any code starts getting checked in.

Is this intended for C as well as C++?  I can certainly see uses -
<tgmath.h> for instance.

Your magic reflection expressions want to be (extended) integer
constant expressions, and in particular suitable for use in template
parameters.  Which I bet you've already thought of, but it does mean
that there are ABI implications here.

>     enum __CVQualifier__
>     {
>       __cv_none, __cv_const, __cv_volatile, __cv_restrict,
>       __cv_const_volatile, __cv_const_restrict, __cv_volatile_restrict,
>       __cv_const_volatile_restrict
>     };

1) Calling these "CV" qualifiers is inappropriate: it's an
   abbreviation for "const or volatile" and now we have restrict too.
   Suggest you just call them qualifiers and use __qual_ as a prefix.

2) These should be bitmasks, so you can write

   if (__builtin_qualifiers (type) & __qual_const)
     /* type is const-qualified; don't care about volatile or restrict */

Other than this it looks great.

zw


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