home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / misc / 3592 < prev    next >
Encoding:
Internet Message Format  |  1992-11-11  |  2.9 KB

  1. Path: sparky!uunet!ukma!usenet.ins.cwru.edu!agate!apple!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: <mwm.2lit@contessa.palo-alto.ca.us> <BxJ39L.LCv@mentor.cc.purdue.edu> <mwm.2lp7@contessa.palo-alto.ca.us> <BxJzzv.4H7@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.2lx7@contessa.palo-alto.ca.us>
  11. Date: 11 Nov 92 09:26:04 PST
  12. Organization: Missionaria Phonibalonica
  13. Lines: 49
  14.  
  15. In <BxJzzv.4H7@mentor.cc.purdue.edu>, hrubin@pop.stat.purdue.edu (Herman Rubin) wrote:
  16. > In article <mwm.2lp7@contessa.palo-alto.ca.us> mwm@contessa.palo-alto.ca.us (Mike Meyer) writes:
  17.  
  18. This all started when herman said:
  19. > >> >> You need explicit pointers to functions when the caller does not know
  20. > >> >> the name of the function being called, but the caller has received a
  21. > >> >> pointer to the function.
  22.  
  23. > >> I will consider any suggestions to do this in a better manner, but I
  24. > >> am not willing to make it any less flexible, nor to put any more burdens
  25. > >> on the writers of the subprogram, nor of the (usually separately compiled)
  26. > >> fill functions.
  27. > >You want to make it better? Two things you can do. First, throw away
  28. > >the silly attachment to pointers per se, and let the compiler handle
  29. > >the trivia. When you call a function with a function as an argument,
  30. > >you give it the name of the function as the argument. When you receive
  31. > >a function as an argument, you declare it - AND USE IT - as a
  32. > >function. That means you can drop the extra "*" on the call, and on
  33. > >the reference to the function in the call. No explicit pointers
  34. > >needed; they are all implicit, and might not be there at all,
  35. > >depending on how good your compiler is.
  36. > The function is not an argument to something else.  I do not see how 
  37. > the code will run any better if we have to use something like
  38. >     superfill(*fl,*des)
  39. > than what I have suggested.
  40.  
  41. Herman, the code probably won't _run_ any better. It will never run
  42. any worse, as a "dumb" implementation would map it directly back to
  43. the pointers you used. The point is that your original statement -
  44. about needing explicit pointers - is _wrong_. I know it's wrong; I do
  45. just what you're talking about in a language with no explicit pointers
  46. all the time. The original code I posted showed such a case exactly. I
  47. apologize for using identifiers that made things clearer instead of
  48. your favorite one-letter-with-no-relation-to-the-problem style.
  49.  
  50. > So just as many pointers are used, anyhow.
  51.  
  52. That's for the dumb compiler, or the worst-case for the smart
  53. compiler. By getting rid of the explicit pointers, you make it
  54. possible for a compiler to notice cases where all the functions being
  55. passed in are known, and to generate better code to take advantage of
  56. that.  In the extreme case, only one such function is used, and a good
  57. compiler will generate inline code for it.
  58.  
  59.     <mike
  60.