Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Caps convention.

Reply
Thread Tools

Caps convention.

 
 
Malcolm
Guest
Posts: n/a
 
      12-20-2003
Use all lower case for ansi c functions, and Capitalise For
Platform-Specific.

If you call something with caps, then your function name requires caps
itself.



 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      12-20-2003
On Sat, 20 Dec 2003 17:27:43 -0000, "Malcolm"
<(E-Mail Removed)> wrote in comp.lang.c:

> Use all lower case for ansi c functions, and Capitalise For
> Platform-Specific.
>
> If you call something with caps, then your function name requires caps
> itself.


No. Any you can't make me.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
Reply With Quote
 
 
 
 
Thomas Matthews
Guest
Posts: n/a
 
      12-20-2003
Malcolm wrote:
> Use all lower case for ansi c functions, and Capitalise For
> Platform-Specific.
>
> If you call something with caps, then your function name requires caps
> itself.


The common style is to use all-caps for constants and macros.
Function name styles differ:
leading word starts lowercase followed by Capitalized words:
thisIsMyFunction
same thing, using underscores:
this_Was_My_Function
starting with Captials:
ThisIsAnotherFunction
This_May_Be_More_Readable
as you suggested:
anansicfunction
another_ansi_function

However, most all good coding styles don't permit function names
to start with '_' (underscores) as these are reserved for
implementations.

This is a religous issue: all a matter of faith. As long as you
are consistent and the names are readble, any style will do. Just
as there is no best religion, there is no best coding style.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      12-20-2003
Thomas Matthews wrote:
> Malcolm wrote:
>
>> Use all lower case for ansi c functions
>> and Capitalize For Platform-Specific.
>>
>> If you call something with caps,
>> then your function name requires caps itself.


No!
That would imply that your API *depends* upon
details of its implementation.

> The common style is to use all-caps for constants and macros.


This is an anachronism.

> Function name styles differ:
> leading word starts lowercase followed by Capitalized words:
> thisIsMyFunction
> same thing, using underscores:
> this_Was_My_Function
> starting with Captials:
> ThisIsAnotherFunction
> This_May_Be_More_Readable
> as you suggested:
> anansicfunction
> another_ansi_function


These aren't really styles. The are typing shortcuts
for programmers with a missing shift key.
The idea was that because capital letters and underscore
required the programmer to hold down the shift key,
they slowed down typing (meaning productivity).
The first style above is a compromise
between readability and typing efficiency.

> However, most all good coding styles
> don't permit function names to start with '_' (underscores)
> as these are reserved for implementations.


Again, this rule has nothing to do with style.
It's just a way to avoid conflicts with the implementation.

> This is a religious issue: all a matter of faith.
> As long as you are consistent and the names are readable,
> any style will do.
> Just as there is no best religion, there is no best coding style.


Yes, but no "true believer" will agree with you.

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-20-2003
Malcolm wrote:

> Use all lower case for ansi c functions, and Capitalise For
> Platform-Specific.
>
> If you call something with caps, then your function name requires caps
> itself.


Taken to its logical conclusion, this requires you to define your entry
point as Main() - and then it won't link.

Duh.

--
Richard Heathfield : http://www.velocityreviews.com/forums/(E-Mail Removed)
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
 
Reply With Quote
 
Arthur J. O'Dwyer
Guest
Posts: n/a
 
      12-20-2003

On Sat, 20 Dec 2003, Richard Heathfield wrote:
>
> Malcolm wrote:
> >
> > Use all lower case for [ANSI C] functions, and Capitalise For
> > Platform-Specific.
> >
> > If you call something with caps, then your function name requires caps
> > itself.

>
> Taken to its logical conclusion, this requires you to define your entry
> point as Main() - and then it won't link.


Only if your main function is Platform-Specific. And in that case
it's off-topic for comp.lang.c anyway, and if you do post it,
*no matter* the capitalization, all you'll get are smiley posts
claiming that it won't link on [your OS here]. No harm, no foul.
(-:

FWIW, except for Malcolm's miscapitalization of the terms "ANSI C",
I basically agree with his statement. I just don't think it really
needed to be broadcast to the world, any more than it would be
appropriate to start a new thread in alt.usage.english to say,
"Start a new paragraph when there's a new speaker," or in comp.programming
to point out that the worst-case running time of Quicksort is O(n^2).
Those who care, already know.

-Arthur
 
Reply With Quote
 
Alexander Bartolich
Guest
Posts: n/a
 
      12-20-2003
begin E. Robert Tisdale:
> These aren't really styles. The are typing shortcuts
> for programmers with a missing shift key.
> The idea was that because capital letters and underscore
> required the programmer to hold down the shift key,
> they slowed down typing (meaning productivity).


And how do you get an underscore without pressing shift?

--
Für Google, Tux und GPL!
 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      12-20-2003

"Richard Heathfield" <(E-Mail Removed)> wrote in message
> Taken to its logical conclusion, this requires you to define your entry
> point as Main() - and then it won't link.
>
> Duh.
>

So this is an issue for comp.std.c. If programs beginning main() were
constrained to be portable ANSI C, whilst platform-specific can start
Main(), then this is a powerful incentive for people to write portable
programs.

Actually main() is often not the entry point for non-ANSI programs.


 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-20-2003
Arthur J. O'Dwyer wrote:
> On Sat, 20 Dec 2003, Richard Heathfield wrote:
>> Malcolm wrote:
>> >
>> > Use all lower case for [ANSI C] functions, and Capitalise For
>> > Platform-Specific.
>> >
>> > If you call something with caps, then your function name requires caps
>> > itself.

>>
>> Taken to its logical conclusion, this requires you to define your entry
>> point as Main() - and then it won't link.

>
> Only if your main function is Platform-Specific.


Or if it /calls/ something Platform-Specific, according to Malcolm.

<snip>

> FWIW, except for Malcolm's miscapitalization of the terms "ANSI C",
> I basically agree with his statement. I just don't think it really
> needed to be broadcast to the world, any more than it would be
> appropriate to start a new thread in alt.usage.english to say,
> "Start a new paragraph when there's a new speaker," or in comp.programming
> to point out that the worst-case running time of Quicksort is O(n^2).
> Those who care, already know.


Quite so. But since we're being so public about it at present, my own
preference is xyz_CamelCase for function names and parameter names in the
xyz library (or, perhaps, the library for which xyz is a suitable
contraction or abbreviation), SEPARATED_UPPER_CASE for type names and
macros, and whatever I feel like for local identifiers.

--
Richard Heathfield : (E-Mail Removed)
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      12-20-2003
"E. Robert Tisdale" <(E-Mail Removed)> writes:
[...]
> > The common style is to use all-caps for constants and macros.

>
> This is an anachronism.


Since when?

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Caps Lock" Key Problem Julie P. Computer Support 11 07-08-2004 04:16 AM
Typical upload speed caps Bishoop Computer Support 7 05-12-2004 03:07 AM
where to buy 1000microF caps for my ABIT m-b (UK)? Geoff Pearson Computer Support 6 10-12-2003 06:32 PM
Baseball caps Mike Digital Photography 10 10-01-2003 09:12 AM
xsl syntax to generate all caps with _ Mikael Petterson XML 3 09-11-2003 05:03 AM



Advertisments