Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.

9.5.3 Lists and E-lists

Lists are just like strings with LONG elements rather than CHAR elements (so they are very much like ARRAY OF LONG). The list equivalent of an E-string is something called an E-list. It has the same properties as an E-string, except the elements are LONG (so could be pointers). Normal lists are most like string constants, except that the elements can be built from variables and so do not have to be constants. Just as strings are not true E-strings, (normal) lists are not true E-lists.

Lists are written using `[' and `]' to delimit comma separated elements. Like string constants a list returns the address of the memory which contains the elements.

For example the following code fragment:

  DEF list:PTR TO LONG, number

is equivalent to:

  DEF list[4]:ARRAY OF LONG, number

Now, which of these two versions would you rather write? As you can see, lists are pretty useful for making your program easier to write and much easier to read.

E-list variables are like E-string variables and are declared in much the same way. The following code fragment declares lt to be an E-list of maximum size 30. As ever, lt is then a pointer (to LONG), and it points to the memory allocated by the declaration.

  DEF lt[30]:LIST

Lists are most useful for writing tag lists, which are increasingly used in important Amiga system functions. A tag list is a list where the elements are thought of in pairs. The first element of a pair is the tag, and the second is some data for that tag. See the Rom Kernel Reference Manual (Libraries) for more details.

Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.