home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / rexx / 1024 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  2.5 KB

  1. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!uvaarpa!concert!borg!news_server!martinc
  2. From: martinc@grover.cs.unc.edu (Charles R. Martin)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Best way to handle arrays and structures in rexx
  5. Message-ID: <MARTINC.92Sep15131526@grover.cs.unc.edu>
  6. Date: 15 Sep 92 17:15:26 GMT
  7. Sender: news@cs.unc.edu
  8. Distribution: comp
  9. Organization: UNC Department of Computer Science
  10. Lines: 52
  11.  
  12. Say I want to implement a parser that constructs a tree using rexx.  How
  13. would I best represent the tree?
  14.  
  15. Seems like the following schemes would work:
  16.  
  17. Put each node of the tree into an array, i.e. a new operation would use
  18. a node count and build the new node using 
  19.  
  20.     ary.nodecount = /* some nice node initialization */
  21.  
  22. Now the data in each node would be some kind of record representing the
  23. node, and it seems there are two ways of doing that -- either I can
  24. assign a string to ary.nodecount and parse that string into its
  25. constituent fields when I need them, or I can build a futher qualified
  26. name onto the ary.ix stem, like ary.ix.left = /* index of the left
  27. child */.
  28.  
  29. Some questions:
  30.  
  31. 1. Other than the parsing time, is there any reason to prefer one over
  32. the other (like, for example, you can't have two '.'s in a name, so
  33. a.b.c would be a syntax error)?
  34.  
  35. 2. I understand that it's common conventionally to keep the size of an
  36. array as ary.0 (although I'd probably prefer ary.size or ary.card it I
  37. were using numeric indices.)  Can I write some expression like
  38.  
  39.     ary.(ary.0) = ...
  40.  
  41. to refer to that value directly?
  42.  
  43. The second approach I've thought of is to generate a new name for
  44. each vertex, then use the stem construction for the fields in that
  45. vertex.  (Although that appears to be very much like using the stem
  46. construction.)  Any advantage to that?
  47.  
  48. And of course, there is always the chance that there are a third fourth,
  49. etc, way of doing it that is both reasonably efficient -- although
  50. efficiency isn't my main concern, since if it were I'd write in C -- and
  51. for some reason better than there.
  52.  
  53. I'd appreciate any information you-all can offer.
  54.  
  55. --
  56. Charles R. Martin/(Charlie)/martinc@cs.unc.edu/(ne crm@cs.duke.edu) 
  57. O/Dept. of Computer Science/CB #3175 UNC-CH/Chapel Hill, NC 27599-3175
  58. H/3611 University Dr #13M/Durham, NC 27707/(919) 419 1754
  59. ----------------------------------------------------------------------
  60. "I am he who walks the States with a barb'd tongue, questioning every
  61. one I meet,/Who are you that wanted only to be told what you knew
  62. before?/ Who are you that wanted only a book to join you in your
  63. nonsense?"  _Leaves of Grass_ xxiii.4.
  64.