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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!psinntp!psinntp!dg-rtp!sheol!throopw
  2. From: throopw@sheol.UUCP (Wayne Throop)
  3. Newsgroups: comp.lang.misc
  4. Subject: Re: Pointers
  5. Summary: still don't need explicit pointers
  6. Message-ID: <721539019@sheol.UUCP>
  7. Date: 12 Nov 92 00:52:48 GMT
  8. References: <BxJzzv.4H7@mentor.cc.purdue.edu>
  9. Lines: 86
  10.  
  11. : From: hrubin@pop.stat.purdue.edu (Herman Rubin)
  12. : Message-ID: <BxJzzv.4H7@mentor.cc.purdue.edu>
  13. :: No, you don't need *explicit* pointers to functions. It's perfectly
  14. :: reasonable (and I would argue, preferable) to allow function names
  15. :: in argument lists.
  16. : The function is not an argument to something else.  I do not see how
  17. : the code will run any better if we have to use something like
  18. :         superfill(*fl,*des)
  19. : than what I have suggested.  All superfill would do is to call *fl,
  20. : after putting more stuff on the stack, and do some more stack management.
  21. : So just as many pointers are used, anyhow.
  22.  
  23. But explicit pointers are not required in any event.  So you want to
  24. bind a variable name to a function globally, as a side effect, instead
  25. of within the scope of some procedure: fine, let there be procedure
  26. *variables* in addition to procedure arguments.  See, ma?  No
  27. explicit pointers.
  28.  
  29. Of course, in C, there is no such notion, but if we treat
  30.  
  31.           void (*functionname)(buffertype*);
  32.           extern void actualfunction(buffertype*);
  33.           buffertype* buffername;
  34.           extern buffertype actualbuffer[];
  35.           
  36. as a quaint way of saying 
  37.  
  38.           variable functionname:   procedure(buffertype),
  39.                    buffername:     reference buffertype;
  40.           external actualfunction: procedure(buffertype),
  41.                    actualbuffer:   buffertype;
  42.  
  43. Then we can simply say things like this, in either C or the
  44. hypothesized language without explicit pointers:
  45.  
  46.           functionname = actualfunction;
  47.           buffername = actualbuffer;
  48.           [...]
  49.           functionname(buffer);
  50.  
  51. (or, if short names are wanted)
  52.  
  53.           var fl:    proc(buf_t),
  54.               des:   ref buf_t;
  55.           ext func:  proc(buf_t),
  56.               buf:   buf_t;
  57.           [...]
  58.           fl = func;
  59.           des = buf;
  60.           [...]
  61.           fl(des);
  62.  
  63. You might claim that "reference" (or "ref") is just "pointer" spelled
  64. sideways, but there is no "address of" operation, no "indirect"
  65. operation, and hence no EXPLICIT pointer operations at all in the
  66. language.
  67.  
  68. In value-oriented languages like lisp, things are done differently
  69. than the above variable-oriented methods.  But even so, even in lisp
  70. (arguably a pointer-bashing language if ever there was one), there
  71. are no explicit pointers, nor need of them.  (In fact, the lack of
  72. explicit pointers in lisp makes it easier to pull space-saving tricks
  73. like cdr-coding, I expect.)
  74.  
  75. : There is no reason why the caller needs to know the NAME of the function,
  76. : in any case.  It is quite possible that even the object code might have
  77. : elided the name.  This is even more the case when the program under which
  78. : the caller is operating may want to change things at run time.
  79.  
  80. There is also no reason why the caller needs to EXPLICITLY INDIRECT the
  81. reference to the function.  This form of referential transparency makes
  82. it much easier to change the declaration of a statically bound
  83. buffer-fill function, and go to a dynamically bound scheme, without
  84. having to change all the places where the definition is referenced.  Or
  85. vice versa: back out of a dynamically bound scheme to save the extra
  86. pointer indirect that it implies, if the funcall is that
  87. time-critical.
  88.  
  89. Of course, referential transparency as a general principle is far out of
  90. fashion these days, despite C++'s addition of the "&" reference
  91. declarator.  Of course, people make an exception for the cases of
  92. generic and method binding; THOSE seem very much in fashion. 
  93. --
  94. Wayne Throop  ...!mcnc!dg-rtp!sheol!throopw
  95.