Inform 7 Home Page / Documentation


§17.22. Precedence

When several different lines of grammar are supplied to meet the same circumstances, it makes a big difference what order they are tried in. For instance, suppose we have:

Understand "photograph [a door]" as photographing.

Understand "photograph [an open door]" as photographing.

The second line is more specific than the first, so Inform takes these grammar lines the other way around: it checks for "open door" before it checks for "door". That didn't matter here, since both lines came out with the same result (the action of photographing), but it matters very much in the next example:

Understand "employ [a door]" as opening.

Understand "employ [an open door]" as entering.

More subtle is a line already seen:

Understand "on/in/inside" or "on top of" as "[within]".

Here Inform puts "on top of" before "on/in/inside", since otherwise only the "on" of "on top of" will be recognised.

Mistakes always take precedence over non-mistakes: this is intended to make sure that

Understand "take umbrage" as a mistake ("Nobody takes umbrage in this story, mister.").

will take precedence over

Understand "take [something]" as taking.

even if there is, in fact, a character called Mr Nimbus Umbrage so that the command could conceivably make sense.

Finally, there are a few grammars where the number of values produced is different in different lines. For example, the Standard Rules include these among the possible "put" commands:

Understand "put [something preferably held] on" as wearing.
Understand "put [other things] on/onto [something]" as putting it on.

One produces a single object, the other produces two. Inform gives precedence to the first of these, that is, it tries the one with fewer values first. This is important when reading commands like "PUT MARCH ON WASHINGTON SHIRT ON", and also prevents bogus auto-completions, in which PUT HAT ON might wrongly be auto-completed as if it were PUT HAT ON THE TABLE.


arrow-up.png Start of Chapter 17: Understanding
arrow-left.png Back to §17.21. Understanding mistakes
arrow-right.png Onward to Chapter 18: Activities: §18.1. What are activities?

*ExampleSome Assembly Required
Building different styles of shirt from component sleeves and collars.

***ExampleLakeside Living
Similar to "Lemonade", but with bodies of liquid that can never be depleted, and some adjustments to the "fill" command so that it will automatically attempt to fill from a large liquid source if possible.