Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Naming convention for structs and types Date: Sat, 14 Jan 2017 15:20:25 -0800 Organization: None to speak of Lines: 27 Message-ID: References: <21902847-5d4a-4cc5-8b5b-bf6692f21cca@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="a3056e3d6a9ef9101ceee550b325befe"; logging-data="13715"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lIFe3bWnes9bNErPbjX6n" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:194wUFRo8G26FD8i+g6IYCMF2c4= sha1:A1i3A+ebZbNuvwf42GZQObHa3Zc= Xref: csiph.com comp.lang.c:101824 Tim Rentsch writes: [...] > Let me offer a counterpoint here. There can be tag names without > having a 'struct', because 'enum' and 'union' also use tags. The > namespace for tags is shared between enum, struct and union, so > a trailing "_s" is not as redundant as it might seem: it serves > to distinguish which of the three categories applies to the tag > in question (and similarly, eg, "_e" or "_u", would identify an > enum or a union). I recommend adopting some stylistic rule (to > be clear, for tag names) like the "_s" convention for just this > reason. Personally I think the "_s" differentiator is okay for > this, but the key point is to have a scheme that makes enum tags, > struct tags, and union tags, be distinct from each other. I don't see how such a convention is useful. A tag name must always be preceded by one of three keywords, struct, union, or enum. That context is enough to tell you what kind of tag it is. A _s, _u, or _e suffix would be purely redundant. It would let you use the same name for a struct and a union, or a struct and an enum, but I wouldn't want to do that anyway. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"