Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!gatech!emory!stiatl!tom
From: tom@stiatl.UUCP (Tom Wiencko)
Newsgroups: comp.sys.ibm.pc
Subject: Re: Spurious Turbo-C warning -- how do I get around it?
Message-ID: <7024@stiatl.UUCP>
Date: 24 Sep 89 15:13:08 GMT
References: <5554@videovax.tv.Tek.com> <6913@stiatl.UUCP> <4216@internal.Apple.COM>
Reply-To: tom@stiatl.UUCP (Tom Wiencko)
Distribution: usa
Organization: Wiencko & Associates, Inc.
Lines: 38

In article <4216@internal.Apple.COM> desnoyer@apple.com (Peter Desnoyers) writes:
>>
>>I would not expect such dogma from someone programming in a heathen 
>>language such as C. In realistic usage it is often much cleaner, easier to 
>>read, and easier to maintain if multiple exit points are used. For 
>>instance, if an error early in a routine requires an exit after a 
>>different clean-up sequence than at the end of the routine, your code is 
>>going to be a lot cleaner if you use two return statements.

I maintain my original position: that such code (in C or any other
"heathen" language you may wish to discuss) is not well structured and
could use a dose of proper design.  The language is far less important
than the design principles used to structure it.

It has always been one of my pet peeves that people who program in C
believe that they can get away with lousy code simply because they are
programming in a language which lets them do it.  This is why I have been
a strong believer in using languages which better enforce structure
requirements (Pascal, Modula-2) for application code, and leave C for
systems and tools and places where it is necessary to break the rules.

>>
>>> In general, warnings like this are there to tell you that you are writing
>>> code which is not well structured, or is not properly taking advantage
>>> of the appropriate C idioms.
>>
>>Single return per function is definitely NOT a C idiom. Always returning a 
>>value from a function declared to return a value is not just C idiom, but 

The idiom I was speaking of was the "for (;;)" instead of the 
"while (TRUE)" construction.  Where you place the return is a structure issue, 
not an idiom issue.

Tom

-- 
Tom Wiencko                                            (w) (404) 977-4515
gatech!stiatl!tom                                  Wiencko & Associates, Inc.