public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Trevor Saunders <tbsaunde@tbsaunde.org>,
	David Malcolm <dmalcolm@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 3/3] matching tokens: C++ parts
Date: Wed, 12 Jul 2017 15:12:00 -0000	[thread overview]
Message-ID: <7385fa94-9fe3-7e61-9476-5e67c4a41e2f@gmail.com> (raw)
In-Reply-To: <20170712131300.u3ofifbzkp52lcxa@ball>

On 07/12/2017 07:13 AM, Trevor Saunders wrote:
> On Tue, Jul 11, 2017 at 11:24:45AM -0400, David Malcolm wrote:
>> +/* Some tokens naturally come in pairs e.g.'(' and ')'.
>> +   This class is for tracking such a matching pair of symbols.
>> +   In particular, it tracks the location of the first token,
>> +   so that if the second token is missing, we can highlight the
>> +   location of the first token when notifying the user about the
>> +   problem.  */
>> +
>> +template <typename token_pair_traits_t>
>
> the style guide says template arguments should be in mixed case, so
> TokenPairTraits, and the _t looks odd to my eyes.
>
>> +class token_pair
>> +{
>> + private:
>> +  typedef token_pair_traits_t traits_t;
>
> I'm not really sure what this is about, you can name it whatever you
> like as a template argument, and this name seems less descriptive of
> what its about.

In generic code, a typedef for a template parameter makes it
possible to refer to the parameter even when it's a member of
a type whose template parameters aren't known (or that's not
even a template).  In the C++ standard library the naming
convention is to end such typedefs with _type (e.g., value_type,
allocator_type, etc.)  GCC itself makes use of this convention
in its hash_table template. (I have no idea if token_pair is
ever used in type generic contexts where the typedef is needed.)

As an aside, it's interesting to note that names that end in _t
are reserved by POSIX, so (purely) pedantically speaking, making
use of them for own symbols is undefined (this is probably one
of the most commonly abused POSIX requirements; even the C++
standard flagrantly disregards it).

Martin

  reply	other threads:[~2017-07-12 15:12 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11 14:51 [PATCH 0/3] C/C++: show pertinent open token when missing a close token David Malcolm
2017-07-11 14:51 ` [PATCH 2/3] matching tokens: C parts David Malcolm
2017-07-11 14:51 ` [PATCH 3/3] matching tokens: C++ parts David Malcolm
2017-07-12 13:13   ` Trevor Saunders
2017-07-12 15:12     ` Martin Sebor [this message]
2017-07-16 17:55       ` Trevor Saunders
2017-08-01 19:47     ` [PATCH 0/3 v2] C/C++: show pertinent open token when missing a close token David Malcolm
2017-08-01 19:47       ` [PATCH 2/3] Matching tokens: C parts (v2) David Malcolm
2017-08-03 17:34         ` Jeff Law
2017-08-04 14:32           ` David Malcolm
2017-08-04 18:09             ` Jeff Law
2017-08-08 20:37               ` David Malcolm
2017-08-09  6:50                 ` Marek Polacek
2017-08-01 19:47       ` [PATCH 3/3] matching tokens: C++ " David Malcolm
2017-08-07 18:25         ` Jason Merrill
2017-08-08 20:26           ` [PATCH] matching tokens: C++ parts (v3) David Malcolm
2017-08-08 20:49             ` [PATCH] Changes for v3 of the C++ patch David Malcolm
2017-08-09 19:26             ` [PATCH] matching tokens: C++ parts (v3) Jason Merrill
2017-08-01 19:47       ` [PATCH 1/3] matching tokens: c-family parts David Malcolm
2017-08-03 17:22         ` Jeff Law
2017-08-02  3:03       ` [PATCH 0/3 v2] C/C++: show pertinent open token when missing a close token Trevor Saunders
2017-08-10 13:39       ` [committed, v3] " David Malcolm
2017-07-11 14:51 ` [PATCH 1/3] matching tokens: c-family parts David Malcolm
2017-07-18 17:23   ` Marek Polacek
2017-07-11 17:28 ` [PATCH 0/3] C/C++: show pertinent open token when missing a close token Martin Sebor
2017-07-11 18:32   ` David Malcolm
2017-07-11 19:30     ` Martin Sebor

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=7385fa94-9fe3-7e61-9476-5e67c4a41e2f@gmail.com \
    --to=msebor@gmail.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tbsaunde@tbsaunde.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).