Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!yale!think!samsung!munnari.oz.au!cluster!metro!bunyip!moondance!uqcspe!qfagus!anvil!keithd From: keithd@anvil.oz (Keith Duddy) Newsgroups: comp.lang.c Subject: Re: questionnaire Message-ID: <1034@anvil.oz> Date: 23 Jan 90 03:15:17 GMT References: <17142@ultima.cs.uts.oz> Organization: Anvil Designs Pty Ltd, Brisbane, Australia Lines: 26 rick_jones@f616.n713.fido.oz (Rick Jones) writes: > pA>4. Do you consider passing a "pointer to a function" to another > pA>function > pA> which will (blindly?) use it to call that function, a "kosher" > pA> programming practice? >I don't know about blindly, but yes I have quite a few programs that do that. >particularly my format() module that does all the work for printf, fprintf, >lprintf, etc. is called with the pointer to an output function, allowing one >function to perform multiple roles. In fact this is the way in which one implements generics in C. If you are storing some generic data type in a module then you must pass in a function sometimes to do comparisons/retrievals etc. As long as the interface and intention of the function is clearly defined then there is no problem. (look at the qsort/bsearch standard libraries). _______________________________________________________________________ __ | keithd@anvil.oz.au /_/ __ o _/ /_ / ) __/ __/ | (07)870 4999 / \ (-' ( ( / / o /_ ' (_( (_/ (_/ (__/ o | Anvil Designs Pty Ltd Don't be stupid Niel, everybody / | PO Box 954, Toowong, knows potatoes can't fart. (_/ | 4066, Australia. [Disclaimer: Anvil Designs Pty Ltd actually encourage creative thought - but they don't want to be involved with creative litigation.]