25.14. Defining phrases in Inform 6

| Chapter 25: Extensions |

| 25.14. Defining phrases in Inform 6

The phrases described in this documentation, such as "end the story", are all defined in the Standard Rules, and are for the most part defined not in terms of other I7 phrases but instead reduced to equivalents in I6. For instance:

> To end the game in death: (- deadflag=3; story_complete=false; -).

The notation "(-" and "-)" indicates that what comes in between is I6 code. The minus sign is supposed to be a mnemonic for the decrease from 7 to 6: later we shall use "(+" and "+)" to go back up the other way, from 6 to 7.

When a phrase is defined as containing only a single command, and that command is defined using I6 - as here - it is compiled in-line. This means that the phrase "end the game in death" will always be translated as "deadflag=1;", rather than being translated into a call to a suitable function whose only statement is "deadflag=1;".

This is an easy case since the wording never varies. More typical examples would be:

> To say (something - number): (- print {something}; -).
> To sort (T - table name) in (TC - table column) order:
> (- TableSort({T}, {TC}, 1); -).

When the braced name of one of the variables in the phrase preamble appears, this is compiled to the corresponding I6 expression at the relevant position in the I6 code. So, for instance,

> say the capacity of the basket

might be compiled to

> print O17_basket.capacity;

because "{something}" is expanded to "capacity of the basket" (I7 code) and then translated to "O17_basket.capacity" (I6 code), which is then spliced into the original I6 definition "print {something};".

Braces "{" are of course significant in I6. A real brace can be obtained by making the character following it a space, and then I7 will not attempt to read it as a request for substitution.

Finally, note that while a normal I7 phrase definition can give a kind as what must be matched, e.g.,

> To release wild tigers into (arena - a room): ...

it is in general a bad idea, and will result in inefficient code, for an phrase defined using I6 to do this. Instead, if possible, match against "object", where any room, region, thing or direction will be a valid match:

> To release wild tigers into (arena - an object): ...

440
| Example Odins Making [is-are] and [it-they] say tokens that will choose appropriately based on the last object mentioned. |
RB

441
| Example Pink or Blue Asking the player to select a gender to begin play. |
RB

Previous | Contents | Next