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

  1. Newsgroups: comp.lang.misc
  2. Path: sparky!uunet!decwrl!pa.dec.com!rdg.dec.com!jch
  3. From: jch@rdg.dec.com (John Haxby)
  4. Subject: Re: Pointers
  5. Message-ID: <1992Nov11.155149.14744@rdg.dec.com>
  6. Sender: news@rdg.dec.com (Mr News)
  7. Organization: Digital Equipment Corporation
  8. 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>
  9. Date: Wed, 11 Nov 1992 15:51:49 GMT
  10. Lines: 48
  11.  
  12. In article <BxIoDv.72J@mentor.cc.purdue.edu>, hrubin@pop.stat.purdue.edu (Herman Rubin) writes:
  13.     ...
  14.  
  15. |> >ALGOL 68 and SIMULA 67 have user-defined types, dynamic memory, and
  16. |> >free-form syntax, no?  And why do you need explicit pointers to functions
  17. |> >when you can have procedure types, like Modula-2?
  18. |> 
  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.  The same holds for pointers to arrays of
  22. |> pointers, and to array descriptors.  If several parts of a program
  23. |> are using the same double buffer, and are even compiled separately,
  24. |> using a pointer to the active buffer, and another one to the refill
  25. |> buffer, would be an excellent way to do things.
  26.  
  27. No you don't.  In Algol 68, procedures are types like anything else
  28. so you can pass a ref proc to a procedure and let the normal coercian
  29. de-reference and de-procedure (ie call) as necessary.  The typing
  30. system requires that only procedures with the right mode (signature) can
  31. be passed as parameters in this way so that the mode of the procedure
  32. is known at compile time.
  33.  
  34. In CLU, you can pass paramaters of type PROCTYPE to accomplish exactly
  35. the same thing, or you can use type parameterization (genericism if you like)
  36. for a similar mechanism for, often, much the same purpose.  CLU doesn't
  37. have references, yet alone pointers.
  38.  
  39. In Modula 3, the type system allows you to pass things as REFANY to
  40. allow the anonyimty you crave in C, but in a type-safe fashion.  Indeed,
  41. the Modula 3 mechanism provides rather more than the C mechanism because
  42. you can tell what you are doing so you don't need to worry about the
  43. more bizarre syntactic mechanisms :-)
  44.  
  45. As someone said in response (I think) to something I said, everything begins
  46. to look like a nail when you only have a pointer to a hammer. In other languages,
  47. older and newer, you have a choice of tools and you can choose the right one
  48. for the job.  [I have four planes and a bastard file: you can do anything with
  49. a bastard file and enough patience and wood; but the right plane will do the job
  50. in a fraction of the time and it will do it right first time].
  51.  
  52.  
  53. -- 
  54. John Haxby, Definitively Wrong.
  55. Digital                <jch@rdg.dec.com>
  56. Reading, England        <...!uknet!wessex!jch>
  57.  
  58. ----------------------------------------------------------------
  59. The opinions expressed herein are my own, not my employers.
  60.