Xref: utzoo comp.lang.c:40445 comp.lang.c++:14374 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!sdl.mdcbbs.com!alanb Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: Prototypes local or global opinions wanted Message-ID: <1991Jun25.154807.1@sdl.mdcbbs.com> From: alanb@sdl.mdcbbs.com Date: 25 Jun 91 15:48:07 BST References: <1991Jun20.202241.7531@msuinfo.cl.msu.edu> <6592@trantor.harris-atd.com> <1991Jun24.132406.1@acad3.alaska.edu> <4845@inews.intel.com> Organization: Shape Data Ltd. (McDonnell Douglas M&E, Cambridge UK) Nntp-Posting-Host: shapeg Nntp-Posting-User: alanb Lines: 35 In article <4845@inews.intel.com>, bhoughto@hopi.intel.com (Blair P. Houghton) writes: > In article <1991Jun24.132406.1@acad3.alaska.edu> fxsdb@acad3.alaska.edu writes: >>In article <6592@trantor.harris-atd.com>, mvm@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@sdl.mdcbbs.com Alan Braggins `cat ~/.disclaimer`