![]() | Chapter 20: Lists | ![]() ![]() |
20.6. Lists of objects |
While there are lists for any kind of value, the form that is useful most often is "list of objects". There is nothing really different about this:
let L be {the pot plant, the foxglove};
makes a list of two objects as usual. However, a much faster and more systematic way to build lists of objects is to use descriptions. If D is any description then "the list of D" produces a list of all the objects matching D. For instance:
let L be the list of open containers;
add the list of open doors to L;
means that L now contains the open containers (if any) followed by the open doors (if any). Or, for example:
let L be the list of things;
remove the list of backdrops from L;
makes a list of all non-backdrops.
As mentioned above, lists of objects can be said in two additional ways:
"[L with definite articles]"
"[L with indefinite articles]"
And as mentioned below, they can be sorted in property value order:
sort L in P order;
sort L in reverse P order;
where P is any value property. In all other respects, lists of objects are no different to other lists.
One special list of objects inside the Inform parser is worth mentioning. This is the "multiple object list", and is used in commands like this:
>GET ALL
foxglove: Taken.
snake's head fritillary: Taken.
After the parser has decided what constitutes "ALL" (a process which can be influenced using the "deciding whether all includes" activity), it forms up a list and then runs through it, starting an action for each in turn. Here the list has two entries and Inform generates the actions "taking the foxglove" and then "taking the snake's head fritillary".
For two technical reasons this isn't stored as a "list of objects that varies" - first because it needs to exist even in low-memory situations where we can't afford full list-processing, and second because there are times when changing it might be hazardous. Instead, two phrases are provided to read the list and to write it back:
let L be the multiple object list;
alter the multiple object list to L;
If there is no multiple object, say if the command was TAKE PEAR, the list will be empty: it won't be a list of size 1. The multiple object list can be read at any time, but should be altered only up to the point when the "generate action rule" in the turn sequence rules takes effect.
| ![]() Building a fishing pole from several component parts that the player might put together in any order. |
|
| ![]() ![]() Manipulating the order in which items are handled after TAKE ALL. |
|
Previous | Contents | Next |