Inform 7 Home Page / Documentation
§27.24. Inform 6 adjectives
There are three ways to specify that an adjective is defined at the I6 level. For example:
Definition: a number is prime rather than composite if I6 routine
"PRIMALITY_TEST" says so (it is greater than 1 and is divisible only by itself and 1).
Inform now actually tests if a number N is prime by calling PRIMALITY_TEST(N), and it assumes that we have also included such a routine in the output. The routine is expected to return true or false accordingly.
The text in brackets does nothing functional, but is the text used in the Lexicon dictionary part of the Phrasebook index for the user's benefit; it should be a brief definition. Extension authors are asked to provide these little definitions, so that their users won't be confused by blank lexicon entries.
The second way makes a more capable adjective, since it can not only be tested, but also made true or false using "now". For example:
Definition: a scene is crucial if I6 routine "SceneCrucial" makes it so
(it is essential to winning).
The difference here is "makes it so", not "says so", and as this implies, the routine has more power. "SceneCrucial" is called with two arguments: SceneCrucial(S, -1) tests whether the scene is crucial or not and returns true or false; SceneCrucial(S, true) must make it true; and SceneCrucial(S, false) must make it false. Another useful difference is that if the kind of value is one which is stored in block form (e.g. for an adjective applying to text), the routine is given a pointer to the block, not a fresh copy.
A third way to define an adjective, which should be used only if speed is exceptionally important, is to provide a "schema" - a sort of I6 macro, like those provided by the C preprocessor. For example:
Definition: a rulebook is exciting if I6 condition
"excitement_array-->(*1)==1" says so (it is really wild).
The escape "*1" is expanded to the value on which the adjective is being tested. (This is usually faster than calling a routine, but in case of side-effects, the "*1" should occur only once in the condition, just as with a C macro.) To repeat: if in doubt, use the I6 routine method above.