home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!swrinde!gatech!destroyer!ncar!noao!amethyst!organpipe.uug.arizona.edu!news
- From: dave@cs.arizona.edu (Dave Schaumann)
- Newsgroups: comp.lang.c
- Subject: Re: Function definition style
- Message-ID: <1992Dec31.023318.4947@organpipe.uug.arizona.edu>
- Date: 31 Dec 92 02:33:18 GMT
- References: <1992Dec30.223045.29467@news2.cis.umn.edu>
- Sender: news@organpipe.uug.arizona.edu
- Reply-To: dave@cs.arizona.edu (Dave Schaumann)
- Organization: University of Arizona
- Lines: 51
- In-Reply-To: wright@staff.tc.umn.edu (Mark Wright)
-
- In article <1992Dec30.223045.29467@news2.cis.umn.edu>, wright@staff (Mark Wright) writes:
- >Is there any good reason not to use the following style for defining
- >functions:
- >
- >type function_name( varname1, varname2, varname3 )
- >
- >type varname1;
- >type varname2;
- >type varname3;
-
- Well, if your compiler can't deal with ANSI-style declarations, that's
- about the only choice you have. Also, if you're extremely concerned
- about portability, and for some reason don't want to use the de-protoizer
- utility that's freely available, you might also do this.
-
- The bad things about this are:
- 1. The compiler can't do parameter type-checking or auto-casting like it
- can with prototypes.
- 2. This style of declarations has subtly different semantics from
- prototyped declarations. A sloppy programmer might decide to
- play mix-n-match, which can lead to subtle, nasty bugs.
- 3. Although it is still supported, presumably old-style declarations
- will someday be one with history. All programs with old-style
- declarations will either have to be abandoned or proto-ized.
-
-
- >I try to use the style in ansi k&r, but I notice that others are using this
- >style and I assume they aren't all using pre-ansi compilers.
-
- IMHO, one should be *very* careful in picking up coding habits from other
- programmers. Often a programmer will use a particular feature or style
- out of laziness or ignorance of superior alternatives.
-
- >My problem is that to use Brief's function listing command the end paren must
- >be on the same line as the function name,
-
- Oh, yeah. Another reason programmers continue bad habits is to support
- broken tools. IMHO, you should complain to the vendor and/or seek an
- alternative. There's at least a few C-function utilities available in
- the comp.sources.(unix|misc) archives. I also have a simple function
- lister I wrote myself, which is not dependant on where you put new lines
- in your code (drop me a line if you're interested...)
-
- If you still think pre-ANSI style declarations are better, just remember
- every time you have a bug caused by mis-matched parameters or return type,
- you should say
-
- "If I were using prototyes, the compiler would've caught this".
-
- --
- Caught an internal error--.brainrc restored
-