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

Re: [PATCH v2] Make fetch-pack a builtin with an internal API

From
APAndy Parkins <andyparkins@gmail.com>
Date
Jul 9, 2007, 13:16 UTC
Message-ID
<200707091416.39949.andyparkins@gmail.com>
In-Reply-To
<20070709115029.GD16032@thunk.org>
On Monday 2007 July 09, Theodore Tso wrote:
Show 7 quoted lines
> On Sun, Jul 08, 2007 at 10:39:41PM -0700, Junio C Hamano wrote:
> > Are _identifiers with leading underscore Kosher thing to do, I
> > wonder...  We do have ones with trailing ones (mostly qsort
> > functions) and I think they are done that way for the sake of
> > standards conformance.
>
> _[a-z]* is kosher for file scopes or function scoping:
Perhaps I'm reading it wrong but:

"All identifiers beginning with an underscore are reserved for ordinary identifiers (functions, variables, typedefs, enumeration constants) with file scope."

Doesn't agree with what you've said. I think that you _can_ use _[a-z]* for labels or structure members - however, not within file or function scope.

However, the rule of thumb I've always used is "don't start identifiers with underscore". I can't think of a situation that would mean you have to use an underscore to start an identifier - so why get into detailed worries about where it's allowed and where it isn't. Just don't use it. The document you linked to gives exactly this advice:

"Don't give anything a name with a leading underscore."
> P.S.  Note that the Linux kernel does not worry about such rules; in
> particular, _[a-z]* is very commonly used at the global scope level,
> without any problems.  It doesn't have to be as portable as git
> probably needs to be, however.

The kernel doesn't use any standard library so there is nothing for it to conflict with. I don't think it's that the kernel doesn't worry about those rules, it's that those rules don't apply (just as they don't for glibc). The underscore rules aren't a limitation of the language, they are a limitation imposed by the standard library.

Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Previous: Theodore TsoNext: Theodore Tso
Message 7 of 10 in “Make fetch-pack a builtin with an internal API”
  1. Make fetch-pack a builtin with an internal APIDaniel Barkalow, Jul 9, 2007
  2. Junio C HamanoJul 9, 2007
  3. Daniel BarkalowJul 9, 2007
  4. René ScharfeJul 9, 2007
  5. Daniel BarkalowJul 9, 2007
  6. Theodore TsoJul 9, 2007
  7. Andy ParkinsJul 9, 2007
  8. Theodore TsoJul 9, 2007
  9. Florian WeimerJul 9, 2007
  10. Andy ParkinsJul 9, 2007

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.