Chapter 11: Phrases
11.13. Phrases which use descriptions

In the chapter on Descriptions, we saw that a description can be any source text which describes one or more objects: it might be as simple as "the Corn Market", or as complicated as "open containers which are in dark rooms". (More or less the only restriction is that it must be unambiguous as to what counts and what does not: "three containers" is ambiguous as a description because it does not say which three.)

In the last section, we saw that it is possible to repeat phrases with a temporary name running through all the things matching a description. Other tricks with descriptions have also turned up: in fact, if D is a description, then

say "You gaze mournfully at [the list of D].";
let the tally be the number of D;
let the surprise prize be a random D;
repeat with item running through D:
    ...

are all standard things to do. These examples make it look as if it must be possible to define phrases which act on descriptions, and in fact it is. For instance:

To enumerate (collection - a description):
    repeat with the item running through the collection:
        say "-- [The item]."

This makes "enumerate lighted rooms" run off a list of lighted rooms in a textual format different from the standard one produced by "say the list of lighted rooms". Inside the definition, "collection" can be used wherever a description might be used: here, for instance, we use it as the range for the repeat loop. These must, however, be descriptions of objects, not values.

Purely as a convenience, we can also write "member of" or "members of" in this context. For instance, in the enumerate definition, it would have been just as good to write "...running through the members of the collection..." in the repeat. (Similarly, we could write "number of members of the collection" or "a random member of the collection", which looks grammatically tidier than writing "number of the collection" or "random of the collection" - though in fact both of these do work.)


173
* Example  Curare
A phrase that chooses and names the least-recently selected item from the collection given, allowing the text to cycle semi-randomly through a group of objects.

RB


PreviousContentsNext