home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / misc / 3576 < prev    next >
Encoding:
Text File  |  1992-11-10  |  1.6 KB  |  56 lines

  1. Path: sparky!uunet!think.com!ames!decwrl!decwrl!contessa!mwm
  2. From: mwm@contessa.palo-alto.ca.us (Mike Meyer)
  3. Subject: Re: Pointers
  4. Newsgroups: comp.lang.misc
  5. Distribution: world
  6. References: <1992Nov7.115620.29967@syacus.acus.oz.au> <1992Nov10.024021.8724@linus.mitre.org> <92Nov10.125426est.47525@neat.cs.toronto.edu> <BxIoDv.72J@mentor.cc.purdue.edu>
  7. X-NewsSoftware: Amiga Yarn 3.4, 1992/08/12 15:49:52
  8. Keywords: 
  9. Summary: 
  10. Message-ID: <mwm.2lit@contessa.palo-alto.ca.us>
  11. Date: 10 Nov 92 15:28:39 PST
  12. Organization: Missionaria Phonibalonica
  13. Lines: 41
  14.  
  15. In <BxIoDv.72J@mentor.cc.purdue.edu>, hrubin@pop.stat.purdue.edu (Herman Rubin) wrote:
  16. > In article <92Nov10.125426est.47525@neat.cs.toronto.edu> tlai@cs.toronto.edu (Tony Wen Hsun Lai) writes:
  17. > >ALGOL 68 and SIMULA 67 have user-defined types, dynamic memory, and
  18. > >free-form syntax, no?  And why do you need explicit pointers to functions
  19. > >when you can have procedure types, like Modula-2?
  20. > You need explicit pointers to functions when the caller does not know
  21. > the name of the function being called, but the caller has received a
  22. > pointer to the function.
  23.  
  24. No, you don't need *explicit* pointers to functions. It's perfectly
  25. reasonable (and I would argue, preferable) to allow function names
  26. in argument lists. In C-oid style, this would be:
  27.  
  28. static char
  29. hook_returning_char(void) {
  30.     return 'a' ;
  31.     }
  32.  
  33. int
  34. main(void) {
  35.     extern void function_expecting_a_hook(char (void)) ;
  36.  
  37.     function_expecting_a_hook(hook_returning_char) ;
  38.     }
  39.  
  40. And, in another file, have:
  41.  
  42.  
  43. void
  44. function_expecting_a_hook(char hook(void)) ;
  45.  
  46.     blah() ;
  47.     foo() ;
  48.     bar() ;
  49.     hook() ;    /* Note: invocation of function of unkown name */
  50.     bletch() ;
  51.     }
  52.  
  53.  
  54.     <mike
  55.