git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] struct *_struct

From
Jared Hance <jaredhance@gmail.com>
Date
Aug 5, 2010, 22:43 UTC
Message-ID
<20100805224321.GA22430@localhost.localdomain>
In-Reply-To
<AANLkTin_6gaYF++N2GBgDsedfo7mY7yG5H99=-DxCa5E@mail.gmail.com>
On Thu, Aug 05, 2010 at 11:20:14AM -0500, Michael Witten wrote:
> On Wed, Aug 4, 2010 at 14:24, Junio C Hamano <gitster@pobox.com> wrote:
> > I hate... "typedef foo struct foo"
> 
> How come?
In my opinion, it creates ambiguity. If I have
    
    typedef struct foo foo;

And I have "foo" used in a code snippet, it is much less easier to see if foo is being used in the type context or if its an instance, since I like to do

    struct foo foo;
which reads much less well as:
    foo foo;

Its also much less easier to grep though to find all the places the type is used. If I do

    $ git grep "foo"
I will end up with the instances and the struct type. whereas I can do
    $ git grep "struct foo"

to find (most|all) of the types, depending on whether the code uses decent practices (there shouldn't be a second space between struct and foo, or a newline between them).

I could also use a similar regular expression to find all the instances (ie, all the instances of foo that aren't prefixed with struct).

Previous: Michael WittenNext: Michael Witten
Message 5 of 8 in “[RFC] struct *_struct”
  1. Jared HanceAug 4, 2010
  2. Junio C HamanoAug 4, 2010
  3. Refactor structures in the form of *_struct.Jared Hance, Aug 4, 2010
  4. Michael WittenAug 5, 2010
  5. Jared HanceAug 5, 2010
  6. Michael WittenAug 6, 2010
  7. Jared HanceAug 6, 2010
  8. Miles BaderAug 6, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.