home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / transput / 1229 < prev    next >
Encoding:
Text File  |  1992-11-20  |  5.5 KB  |  131 lines

  1. Newsgroups: comp.sys.transputer
  2. Path: sparky!uunet!mcsun!sun4nl!dutrun!dutrun2!dutncp8!rob
  3. From: rob@pact.nl (Rob Kurver)
  4. Subject: Re: Recursion in occam
  5. Message-ID: <rob.722265724@dutncp8>
  6. Sender: news@dutrun2.tudelft.nl (UseNet News System)
  7. Nntp-Posting-Host: dutncp8.tn.tudelft.nl
  8. Organization: PACT, Delft, The Netherlands
  9. References: <142@autro1.UUCP> <rob.722177288@dutncp8> <1992Nov20.102603.2898@titan.inmos.co.uk>
  10. Date: Fri, 20 Nov 1992 13:22:04 GMT
  11. Lines: 118
  12.  
  13. In <1992Nov20.102603.2898@titan.inmos.co.uk> rob@icarus.inmos.co.uk (Robin Pickering) writes:
  14.  
  15. >In article <rob.722177288@dutncp8> rob@pact.nl (Rob Kurver) writes:
  16. >>In <142@autro1.UUCP> teig@autro1.UUCP (Oyvind Teig) writes:
  17. >>
  18. >>>Recursion of occam-2 or -3
  19. >>
  20. >>>I have seen enough of stack overflow errors to appreciate the lack
  21. >>>of recursion in occam.
  22. >>
  23. >>Recursion + stack-checking -> no stack overflow.
  24. >>
  25. >...
  26. >>
  27. >>When I say "stack checking" I mean "stack checking plus expansion if
  28. >>necessary".  By checking the stack and expanding it if necessary, you
  29. >>remove the stack overflow.
  30.  
  31. >The system you describe does not "remove stack overflow", it simply makes
  32. >it impossible for the programmer to deduce the circumstances under which
  33. >a stack overflow will occur.
  34.  
  35. In my book, stack overflow means using memory past the end of the stack,
  36. which typically results in rather fatal problems.  By extending the stack
  37. when needed it no longer overflows.
  38.  
  39. Yes, to extend the stack you do require dynamic memory allocation.
  40. Now, if you run out of memory at this point you're in trouble.  I would
  41. call this a memory problem, not a stack overflow problem.  Memory can be
  42. exhausted on any system with limited amounts of physical and/or logical
  43. memory, not just on a system that extends the stack when necessary.
  44.  
  45. >I can just see it now, an airliner on final approach, pilot hits the
  46. >undercarriage lever:
  47.  
  48. >"Please wait, stack extension in progress"
  49. >....
  50. >"Stack extension failed (memory fragmented)"
  51. >"Error flag set (please re-boot)"
  52.  
  53. Yes, that would be inconvenient, wouldn't it?  But then, it would also
  54. be inconvenient if the machine got stuck in an infinite loop, or
  55. misbehaved due to one of a zillion other reasons.
  56.  
  57. >Get real, OCCAM was designed for programs where it was fairly important
  58. >to the programmer to be able to predict how the end system would behave.
  59. >Don't ask for OCCAM to have features introduced which break this critical
  60. >functionality.
  61.  
  62. Do you really think recursion is the only thing inhibiting a prediction
  63. about end system behavior?  Everything else can be checked by compilers?
  64. It is never possible for an Occam program to be waiting for a value that
  65. never arrives, or not in time?  An Occam compiler can tell you all this
  66. at compile-time, because there's no recursion?
  67.  
  68. >If you want want quicker development cycles and don't mind indeterminate 
  69. >behaviour of your system at run-time, fine use C with these kinds of
  70. >extensions.
  71.  
  72. I would hardly call recursion an extension to C.  Or to most other
  73. programming languages, for that matter.  Neither is stack extension
  74. an extension to C, as C does not define stacks, nor what should happen
  75. with them when they run out of space.
  76.  
  77. >            Nothing wrong with that, for a certain class of applications
  78. >this is a perfectly acceptable programming environment (I use it a lot).
  79. >However please don't use such a system to develop software for any 
  80. >airliner that I might travel on! (or any other kind of system where failure
  81. >is anything other than a moderate inconvenience).
  82.  
  83. I fail to see how a program (written in Occam or any other language) is
  84. safe if and only if it does not use recursion.  This would have major
  85. implications for the design of critical systems!
  86.  
  87. Recursion with stack extension is just a special form of dynamic
  88. memory.  The problem with dynamic memory is that it is a scarce
  89. resource: you don't know when it will run out, and you don't want it
  90. to run out at the wrong moment.  Now you can do one of two things:
  91. not support dynamic memory in the hope it will not be needed, or
  92. support it the best you can so it can be controlled.
  93.  
  94. When dynamic memory is not supported people will have to jump through
  95. hoops when they need it anyways (there's been plenty of testimony to
  96. that in recent days), and they are bound to make a mistake sooner or
  97. later.
  98.  
  99. By supporting it and educating users about the potential problems
  100. with it, you give programmers the choice to use it or not.  If they
  101. don't need it, fine, you don't run into problems with it.  If they
  102. do need it, they at least have working support for it.
  103.  
  104. Back to recursion:  if recursion is supported programmers can either
  105. use it or not.  If they decide not to use it, fine, they don't run
  106. into any problems with it (as the compiler system will be able to
  107. determine so at link-time and allocate all stacks statically).  If
  108. they do need it, at least they have working support for it, and they
  109. know what the consequences may be.
  110.  
  111. Similar arguments can be applied to iteration, replication, etc.
  112.  
  113. Anyways, I'd be very interested in an explanation of the special
  114. position of memory as a scarce resource.  What about time?  What
  115. about disk storage?  Perhaps files should be disallowed as well,
  116. since they may fill up your disk and your plane may crash?
  117.  
  118. >--
  119. >   Rob.
  120.  
  121. Cheers. - Rob
  122.  
  123. P.S.: I've been told that the original pre-transputer Occam language
  124.       (I think it was implemented on a VAX back then) did support
  125.       recursion.  Can anybody confirm or deny this?
  126. --
  127.      PACT                   Rob Kurver
  128.     Foulkeslaan 87         rob@pact.nl
  129.    2625 RB Delft     ph: +31 15 616864 
  130.   The Netherlands   fax: +31 15 610032
  131.