From: Ian Lance Taylor <iant@golang.org>
To: J Decker <d3ck0r@gmail.com>
Cc: GCC Development <gcc@gcc.gnu.org>
Subject: Re: C2X Proposal, merge '.' and '->' C operators
Date: Sat, 21 Dec 2019 18:51:00 -0000 [thread overview]
Message-ID: <CAKOQZ8xv-K_=1GnyS-uueU+pHRtvg6-mf3qdzaG9ZAmyqwKsXA@mail.gmail.com> (raw)
In-Reply-To: <CAA2GJqVPWubUcxJpFwS9Lu4vJWMHmZxVp4WSs-igdyOmo7AyAA@mail.gmail.com>
On Mon, Dec 16, 2019 at 5:52 AM J Decker <d3ck0r@gmail.com> wrote:
>
> 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.
>
> It should be very evident to the compiler whether the token before '.' or
> '->' is a pointer to a struct/union or a struct/union, and just build the
> appropriate output.
>
> The source modification for the compiler is very slight, even depending on
> flag_c2x(that's not it's name). It ends up changing a lot of existing
> lines, just to change their indentation; but that shouldn't really count
> against 'changed lines'.
>
> I'm sure, after 4 score and some years ('78-19) that it must surely have
> come up before? Anyone able to point me to those existing proposals?
For what it's worth, that is how Go works. The '.' operator is used
for struct fields regardless of whether the left hand operand is a
struct or a pointer to a struct.
Ian
next prev parent reply other threads:[~2019-12-21 18:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 13:51 J Decker
2019-12-17 4:59 ` J Decker
2019-12-17 10:53 ` Florian Weimer
2019-12-20 19:59 ` J Decker
2019-12-20 20:04 ` J Decker
2019-12-20 20:16 ` J Decker
2019-12-21 18:27 ` Eric Gallager
2019-12-21 18:51 ` Ian Lance Taylor [this message]
2019-12-21 23:04 ` Eric Botcazou
2019-12-21 19:11 ` Allan Sandfeld Jensen
2019-12-27 6:23 ` J Decker
2019-12-27 14:44 ` Tadeus Prastowo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKOQZ8xv-K_=1GnyS-uueU+pHRtvg6-mf3qdzaG9ZAmyqwKsXA@mail.gmail.com' \
--to=iant@golang.org \
--cc=d3ck0r@gmail.com \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).