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.


On Sun, Mar 09, 2003 at 07:42:13PM -0800, Zack Weinberg wrote:
> 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.

Yes.

> 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.

Thought of and implemented.  :-)

I wouldn't mind a subthread forking here and discussing the ABI implications.
These are meant to be removed/collapsed/folded/whatever before code
generation begins.  All reflection work should take place on the host,
none on the target.

For example, the "is it const" code fragment you have below -- which,
incidentally, I already have wrappers for :-) -- becomes

    if (true)

after builtins are expanded.


> >     enum __CVQualifier__
> 
> 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.

Good idea.

> 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 */

They already are; I left out the enum values because I thought it might be
a distraction, but I should have left them in.  Choices which are mutually
exclusive start at 0 and increase monotonically; ones such as __Qualifier__
and __SpecialFunctions__, for which multiple choices are possible, are
bitmasks for precisely the above usage.


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams


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