home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / misc / 3758 < prev    next >
Encoding:
Text File  |  1992-11-18  |  3.7 KB  |  76 lines

  1. Newsgroups: comp.lang.misc
  2. Path: sparky!uunet!gatech!news.byu.edu!hamblin.math.byu.edu!sol.ctr.columbia.edu!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!udel!pervert!louie!dori.cis.udel.edu!carroll
  3. From: carroll@dori.cis.udel.edu (Mark C. Carroll)
  4. Subject: Re: Pointers
  5. Message-ID: <1992Nov18.153426.1646@udel.edu>
  6. Sender: usenet@udel.edu (USENET News Service)
  7. Nntp-Posting-Host: dori.cis.udel.edu
  8. Organization: University of Delaware, Newark
  9. References: <BxIoDv.72J@mentor.cc.purdue.edu> <1992Nov15.033115.3324@udel.edu> <BxrABr.KyE@mentor.cc.purdue.edu>
  10. Date: Wed, 18 Nov 1992 15:34:26 GMT
  11. Lines: 63
  12.  
  13. In article <BxrABr.KyE@mentor.cc.purdue.edu> hrubin@mentor.cc.purdue.edu (Herman Rubin) writes:
  14. ]In article <1992Nov15.033115.3324@udel.edu> carroll@thorin.cis.udel.edu (Mark C. Carroll) writes:
  15. ]]In article <BxIoDv.72J@mentor.cc.purdue.edu> hrubin@pop.stat.purdue.edu (Herman Rubin) writes:
  16. ]
  17. ]            ........................
  18. ]
  19. ]]You need *some* way of passing functions as arguments. Pointers are
  20. ]]most definitely *not* necessary. Functions can be passed many ways -
  21. ]]perhaps by some form of name passing, perhaps by passing closures,
  22. ]]perhaps by passing some sort of magical function id, perhaps...
  23. ]
  24. ]]The implementation model doesn't matter. All that matters is that you
  25. ]]be able to pass functions as arguments and call the functions that you
  26. ]]receive as arguments.
  27. ]
  28. ]When I want to call (not pass as an argument) the function or procedure
  29. ]which is designated somewhere, I effectively want a pointer.  There is
  30. ]a little known notation in logic for this, but it still is a pointer.
  31. ]
  32. ]The example I gave is to call the function_whose_name_I_do_not_know
  33. ]of the argument_whose_name_I_do_not_know.  What I do know is a way
  34. ]to contact that part of the program which does know.  Whatever you
  35. ]call that, it is using pointers.  BTW, in that example, I also
  36. ]want to use elements of the remote argument to read the buffer.
  37.  
  38. So what??
  39.  
  40. You are _still_ just passing functions around the program. It doesn't
  41. matter how it gets done. The program can _still_ pass the function as
  42. a closure, or as an identier, or as a magic hash-code. Who cares how
  43. it's passed? What matters is that you need to be able to pass a
  44. function around the program as an argument. You need to be able to
  45. call that function anywhere where it was passed as an argument. That's
  46. it. Why do you insist on forcing the compiler to use a restrictive
  47. implementation when that restriction does not give you _any_ advantage
  48. of _any_ kind.
  49.  
  50. You're insisting on using a uselessly complex, restrictive, and
  51. obfuscatory abstraction. Function pointers in a language like C carry
  52. a _lot_ more garbage than first-class functions. Why do you insist
  53. on that baggage when it doesn't buy you anything?
  54.  
  55. Consider Modula-3.  In Modula-3, you have procedure types. Procedures
  56. get passed around the program as arguments. When you receive a
  57. procedure argument, you can apply that procedure argument. That's
  58. _exactly_ the same thing as passing function pointers in C. The
  59. difference is, you're _only_ capturing the necessary abstraction.
  60.  
  61. Or consider Scheme. In Scheme, you can pass closures around your
  62. program. (A closure is a pair containing an environment and a sequence
  63. of code.) By using closures, you get absolutely everything that you're
  64. demanding from function pointers, only it's far more general with _no_
  65. runtime cost.  
  66.  
  67. Why do you believe that Cs function pointers are preferable to Mod-3's
  68. procedure types or Scheme's closures?
  69.  
  70.     <MC>
  71. -- 
  72. [ Mark Craig Carroll <MC> ] You say you know no tricks, have no talents -
  73. [ U of Delaware, CIS Dept ] Isn't everyone supposed to have their own?
  74. [ Grad Student/Lab Hacker ] Yes, but few are obvious. Few draw notice to those
  75. [ carroll@udel.edu        ] who posess them, like flags waving themselves.
  76.