home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / rexx / 783 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  4.1 KB

  1. Path: sparky!uunet!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!sejnet.sunet.se!eric
  2. From: eric@sejnet.sunet.se (Eric Thomas)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: do over stem
  5. Message-ID: <1992Aug26.025338.1@sejnet.sunet.se>
  6. Date: 26 Aug 92 02:53:38 GMT
  7. References: <179f67INNkfm@stanley.cis.Brown.EDU> <ANDERS.92Aug25001604@lise3.lise.unit.no>
  8. Sender: news@sunic.sunet.se
  9. Reply-To: ERIC@SEARN.SUNET.SE
  10. Organization: SUNET, Stockholm, Sweden
  11. Lines: 108
  12.  
  13. In article <ANDERS.92Aug25001604@lise3.lise.unit.no>, anders@lise3.lise.unit.no (Anders Christensen) writes:
  14. > In article <179f67INNkfm@stanley.cis.Brown.EDU> Andre_Lehovich@Brown.Edu (Andre Lehovich) writes:
  15. >> I want to be able to loop a variable over a stem, like so:
  16. >>[...]
  17. >> do i over foo.
  18. >>   say i
  19. >> end
  20. >
  21. > OK, here are some possible problems, or at least some points which has
  22. > to be cleared up:
  23. > 1) You can in general not expect to get the list in any predefined
  24. >    order.
  25.  
  26. I don't care about the order.
  27.  
  28. > 2) What if you set a new compound variable during the loop.
  29.  
  30. The behaviour should be well defined, either a run-time error or a consistent
  31. behaviour (you always/never see the new variable), I don't care either since I
  32. won't set new variables in the loop.
  33.  
  34. > 3) Tails can contain any character, not just "nice" whole numbers
  35.  
  36. This is precisely what I would have liked the "do over" for, 6 years ago. Now
  37. it's too late, I am moving away from REXX as fast as I can.
  38.  
  39. > why do you want to
  40. > do this? It does not add anything to the language that you can't
  41. > easily control in other ways. 
  42.  
  43. No but it saves me a lot of programming time and would significantly improve
  44. performance while decreasing memory requirement for some programs. I can't
  45. count the number of times I had to write code like:
  46.  
  47.  list = ''
  48.  Do <whatever, read a file or something>
  49.     If blah Then
  50.      Do
  51.         k.x = something
  52.         list = list x
  53.      End
  54.     (...)
  55.     Select
  56.       When bluh Then
  57.         Do
  58.            k.x = something
  59.            list = list x
  60.         End
  61.     (...)
  62.     End
  63.  End
  64.  
  65. When your stem has 20 tails, it is only a royal pain in the butt to program
  66. this way. But when it has 5000 and you are happily adding the 5001st
  67. userid@node to the nice 150kb 'list' variable, then copying it back into
  68. 'list', and off we go to number 5002, it hurts. It doesn't only hurt you, it
  69. hurts the whole system to spend your life copying buffers of 150kb to a scratch
  70. 150kb location, appending 20 bytes, and copying back to another 150kb buffer,
  71. then releasing the first one. Of course you don't do that, you do:
  72.  
  73.  li = 1
  74.  Do <whatever, read a file or something>
  75.     If blah Then
  76.      Do
  77.         k.x = something
  78.         If Length(list.li) < 4000
  79.          Then list.li = list.li x
  80.          Else
  81.           Do
  82.              li = li + 1
  83.              list.li = x
  84.           End
  85.      End
  86.     (...)
  87.     Select
  88.       When bluh Then
  89.         Do
  90.            k.x = something
  91.            If Length(list.li) < 4000
  92.             Then list.li = list.li x
  93.             Else
  94.              Do
  95.                 li = li + 1
  96.                 list.li = x
  97.              End
  98.         End
  99.       (...)
  100.     End
  101.  End
  102.  
  103. Even more entertaining to code, even more intuitive to understand, but at least
  104. the paging volume doesn't go into one of its fits of schyzophrenia during which
  105. it thinks it is a washing machine and acts as such. The only REXX construct
  106. that scales up is the stem, so why should I have to use a stupid linear
  107. variable and duplicate a lot of information (especially when the stem doesn't
  108. store that much data) when all I need is a way to run over all the existing
  109. tails of the stem?
  110.  
  111. By the way, I have implemented such a stem system in PASCAL. Variables are
  112. presented in the order in which they were created. If you create a new variable
  113. in the loop, you will see it before the loop ends. If you drop a variable you
  114. have not seen yet, you will not see it. If you drop the current one, you will
  115. see the next one just the same. It wasn't particularly difficult to implement,
  116. and it would have been very easy to generate an error code or run-time error if
  117. you attempt to touch the stem while it is being scanned.
  118.  
  119.   Eric
  120.