Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Caps convention. (http://www.velocityreviews.com/forums/t316655-caps-convention.html)

Malcolm 12-20-2003 05:27 PM

Caps convention.
 
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.




Jack Klein 12-20-2003 05:55 PM

Re: Caps convention.
 
On Sat, 20 Dec 2003 17:27:43 -0000, "Malcolm"
<malcolm@55bank.freeserve.co.uk> 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

Thomas Matthews 12-20-2003 06:30 PM

Re: Caps convention.
 
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


E. Robert Tisdale 12-20-2003 07:08 PM

Re: Caps convention.
 
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.


Richard Heathfield 12-20-2003 07:23 PM

Re: Caps convention.
 
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 : binary@eton.powernet.co.uk
"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

Arthur J. O'Dwyer 12-20-2003 07:54 PM

Re: Caps convention.
 

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

Alexander Bartolich 12-20-2003 08:15 PM

Re: Caps convention.
 
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!

Malcolm 12-20-2003 08:28 PM

Re: Caps convention.
 

"Richard Heathfield" <dontmail@address.co.uk.invalid> 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.



Richard Heathfield 12-20-2003 09:39 PM

Re: Caps convention.
 
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 : binary@eton.powernet.co.uk
"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

Keith Thompson 12-20-2003 10:51 PM

Re: Caps convention.
 
"E. Robert Tisdale" <E.Robert.Tisdale@jpl.nasa.gov> writes:
[...]
> > The common style is to use all-caps for constants and macros.

>
> This is an anachronism.


Since when?

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <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)


All times are GMT. The time now is 10:51 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.