C2X Proposal, merge '.' and '->' C operators
J Decker
d3ck0r@gmail.com
Fri Dec 20 19:59:00 GMT 2019
On Tue, Dec 17, 2019 at 2:53 AM Florian Weimer <fweimer@redhat.com> wrote:
> * J. Decker:
>
> > Here's the gist of what I would propose...
> > https://gist.github.com/d3x0r/f496d0032476ed8b6f980f7ed31280da
> >
> > In C, there are two operators . and -> used to access members of struct
> and
> > union types. These operators are specified such that they are always
> paired
> > in usage; for example, if the left hand expression is a pointer to a
> struct
> > or union, then the operator -> MUST be used. There is no occasion where .
> > and -> may be interchanged, given the existing specification.
>
> This is incompatible with C++. I don't think it's worthwhile to change
> C in this way.
>
ya, while I only just saw this, I thought shortly after posting that c++
compatibility might be an issue; and they have separate operators overrides
for -> and . (which V8 uses such that `Local<Object> lo;` `lo.IsEmpty();`
and `lo->Get()` are interchangeable.
However, if not specifically overridden it could be possible to make a
similar change there. (and conversely not having the operator support the
C++ back port wouldn't be an issue). It's still an error in the native
language context to use '.' on a pointer or '->' on a class/struct... and
the modification is really a patch to that error to just do the other
thing...
>
> Thanks,
> Florian
>
>
More information about the Gcc
mailing list