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