From: Jared Hance <jaredhance@gmail.com>
To: git@vger.kernel.org
Subject: Re: [RFC] struct *_struct
Date: Fri, 6 Aug 2010 08:29:20 -0400 [thread overview]
Message-ID: <20100806122920.GA2346@localhost.localdomain> (raw)
In-Reply-To: <4c5b8819.4f3fdc0a.14ad.22b1@mx.google.com>
On Thu, Aug 05, 2010 at 08:57:13PM -0700, Michael Witten wrote:
> On Wed, Aug 4, 2010 at 14:24, Junio C Hamano <gitster@pobox.com> wrote:
> >>> I hate... "typedef foo struct foo"
>
> On Thu, Aug 05, 2010 at 11:20:14AM -0500, Michael Witten wrote:
> >> How come?
>
> On Thu, Aug 5, 2010 at 17:43, Jared Hance <jaredhance@gmail.com> wrote:
> Those are valid points, but I'm not sure they have a practical basis;
> your problems are largely solved by capitalization conventions
> (which essentially provide shorter replacements for `struct '):
>
> typedef struct { /* ... */ } Foo;
> Foo foo;
I agree, thats much better. The original hate was on "struct foo foo".
For some reason, I still prefer the version without the typedef,
though.
> Unfortunately, such conventions don't enjoy the benefit of semantic
> protection. However, language-aware source navigation tools (like ctags)
> should be able to solve that problem and are probably more efficient
> in navigation time than grepping.
>
> Moreover, the form:
>
> foo foo;
>
> is probably not that problematic in practice; it's presence is likely
> to be short lived for 2 reasons:
>
> * Subjectively : everyone thinks it looks awful.
> * Objectively : It's technically constrained.
>
> The typedef declaration:
>
> typedef /*type*/ foo;
>
> introduces the typedef name `foo' into the `ordinary identifier'
> name space; consequently, the declaration:
>
> foo foo;
>
> cannot even occur in the same scope as the typdef, and when
> it does occur in an inner scope, it hides the original typdef
> name `foo' for all subsequent inner scopes:
>
> typedef struct {char x;} foo;
>
> foo foo; // error: attempt to redeclare `foo'.
> foo a;
>
> int main()
> {
>
> foo foo; // OK; hide typedef name with variable `foo'
> foo b; // error: `foo' is not a type.
>
> {
>
> foo c; // error: `foo' is not a type.
>
> typedef struct {char x;} foo; // OK; hide variable `foo'
>
> foo foo; // error: attempt to redeclare `foo'
> foo d;
>
> d = a; // error: anonymous structs are always different types.
>
> {
> foo foo; // OK; hide typedef name with variable `foo'
> d = foo; // OK; same type
> foo e; // error: `foo' is not a type.
> }
>
> {
> foo foo; // OK; hide typedef name with variable `foo'
> d = foo; // OK; same type
> foo f; // error: `foo' is not a type.
> }
>
> }
>
> }
>
> Sincerely,
> Michael Witten
I agree here too. By the way, my comments were mostly against
specifically "typedef foo struct foo", since that what was
specifically mentioned.
next prev parent reply other threads:[~2010-08-06 12:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-04 15:08 [RFC] struct *_struct Jared Hance
2010-08-04 19:24 ` Junio C Hamano
2010-08-04 21:38 ` [PATCH] Refactor structures in the form of *_struct Jared Hance
2010-08-05 16:20 ` [RFC] struct *_struct Michael Witten
2010-08-05 22:43 ` Jared Hance
2010-08-06 3:57 ` Michael Witten
2010-08-06 12:29 ` Jared Hance [this message]
2010-08-06 2:28 ` Miles Bader
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=20100806122920.GA2346@localhost.localdomain \
--to=jaredhance@gmail.com \
--cc=git@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.