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

  1. Newsgroups: comp.lang.misc
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
  3. From: hrubin@pop.stat.purdue.edu (Herman Rubin)
  4. Subject: Re: Pointers
  5. Message-ID: <BxJzzv.4H7@mentor.cc.purdue.edu>
  6. Sender: news@mentor.cc.purdue.edu (USENET News)
  7. Organization: Purdue University Statistics Department
  8. References: <mwm.2lit@contessa.palo-alto.ca.us> <BxJ39L.LCv@mentor.cc.purdue.edu> <mwm.2lp7@contessa.palo-alto.ca.us>
  9. Date: Wed, 11 Nov 1992 13:26:18 GMT
  10. Lines: 66
  11.  
  12. In article <mwm.2lp7@contessa.palo-alto.ca.us> mwm@contessa.palo-alto.ca.us (Mike Meyer) writes:
  13. >In <BxJ39L.LCv@mentor.cc.purdue.edu>, hrubin@mentor.cc.purdue.edu (Herman Rubin) wrote:
  14. >> In article <mwm.2lit@contessa.palo-alto.ca.us> mwm@contessa.palo-alto.ca.us (Mike Meyer) writes:
  15. >> >> You need explicit pointers to functions when the caller does not know
  16. >> >> the name of the function being called, but the caller has received a
  17. >> >> pointer to the function.
  18.  
  19. >> >No, you don't need *explicit* pointers to functions. It's perfectly
  20. >> >reasonable (and I would argue, preferable) to allow function names
  21. >> >in argument lists.
  22.  
  23.             ....................
  24.  
  25. >Herman Rubin finding something difficult to read? That's amazing,
  26. >considering what you call "obvious" code. Maybe it's the lack of
  27. >extraneous characters that serve little or no useful purpose.
  28.  
  29. I presume that those who like 500-character names :-) might find it 
  30. surprising that some people find that hard to read.
  31.  
  32. >> The way that I would want to use pointers
  33. >> would be to have fl as the pointer to a fill function, and des as the
  34. >> pointer to a descriptor array, of which the first two arguments would
  35. >> be pointers to the current element of the buffer and the bounding position,
  36. >> and then when it is needed make sure that the current element is correct,
  37. >> and issue the call
  38.  
  39. >>     *fl(*des);
  40.  
  41. >No problem. That call would look like:
  42.  
  43. >    fl(*des) ;
  44.  
  45. >> I will consider any suggestions to do this in a better manner, but I
  46. >> am not willing to make it any less flexible, nor to put any more burdens
  47. >> on the writers of the subprogram, nor of the (usually separately compiled)
  48. >> fill functions.
  49.  
  50. >You want to make it better? Two things you can do. First, throw away
  51. >the silly attachment to pointers per se, and let the compiler handle
  52. >the trivia. When you call a function with a function as an argument,
  53. >you give it the name of the function as the argument. When you receive
  54. >a function as an argument, you declare it - AND USE IT - as a
  55. >function. That means you can drop the extra "*" on the call, and on
  56. >the reference to the function in the call. No explicit pointers
  57. >needed; they are all implicit, and might not be there at all,
  58. >depending on how good your compiler is.
  59.  
  60. The function is not an argument to something else.  I do not see how 
  61. the code will run any better if we have to use something like
  62.  
  63.     superfill(*fl,*des)
  64.  
  65. than what I have suggested.  All superfill would do is to call *fl,
  66. after putting more stuff on the stack, and do some more stack management.
  67. So just as many pointers are used, anyhow.
  68.  
  69. There is no reason why the caller needs to know the NAME of the function,
  70. in any case.  It is quite possible that even the object code might have
  71. elided the name.  This is even more the case when the program under which
  72. the caller is operating may want to change things at run time.  
  73. -- 
  74. Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
  75. Phone: (317)494-6054
  76. hrubin@snap.stat.purdue.edu (Internet, bitnet)  
  77. {purdue,pur-ee}!snap.stat!hrubin(UUCP)
  78.