Prototypes local or global opinions wanted

alanb at sdl.mdcbbs.com alanb at sdl.mdcbbs.com
Tue Jun 25 15:48:07 AEST 1991


In article <4845 at inews.intel.com>, bhoughto at hopi.intel.com (Blair P. Houghton) writes:
> In article <1991Jun24.132406.1 at acad3.alaska.edu> fxsdb at acad3.alaska.edu writes:
>>In article <6592 at trantor.harris-atd.com>, mvm at caesun6.harris-atd.com
> (Matt Mahoney) writes:
>>> Functions are always global, so their prototypes should be global too.
>>
>>Functions can be declared locally with local prototypes which was, I believe,
>>the focus of the question.  I much prefer global functions, as this encourages
>>writing general functions which are reused throughout the code, and can easily
>>be #included.
> 
> Block-scoped function definitions can import block-scoped
> variables.
> 
> Very handy when hacking a decision tree into a former
> straight-flow construct.
> 
> 				--Blair
> 				  "Information hiding in the rushes."

But block-scoped function definitions (as opposed to declarations) aren't
available in C (or C++)?
(Thinks - hang on, you're allowed block scope classes with member functions
aren't you - checks manual - local classes have function scope, and can
import only static variables from the enclosing scope - Ellis & Stroustrup 9.8)

Has anyone out there found this useful? Or was this a recommendation to use 
something other than C/C++ to get nested functions?

I agree with the "declare it once only" (in the include file) principle.
C++ type-safe linkage does at least give you a chance of catching incorrect
local declarations though (unless they're extern "C").


alanb at sdl.mdcbbs.com      Alan Braggins      `cat ~/.disclaimer`



More information about the Comp.lang.c mailing list