For people who know more about how Inform runs behind-the-scenes, I have a question.
When Inform is dealing with code that adds a pile of grammar tokens to an object and has ‘when’ qualifications on it -
e.g. Understand "a/b/c/d/e/f/g/h/i/j" as part-of-the-alphabet when alphabet-time is true;
– Does it check the ‘when’ qualification first before bothering to try to match any of the tokens? I’m guessing it does because that seems like a more efficient way to run things.
-Wade
3 Likes
Yes, it does. If the when/while
condition is not met, then the Understand
line is considered to be inapplicable.
The relevant I6 logic is compiled into the applicable parse_name()
routine(s). For example, with code:
A foo is a kind of thing.
Bar is a scene.
Understand "baz" as a foo when bar is happening.
the resulting I6 (in 6M62) is:
[ Parse_Name_GV93
...
if (Cond_Token_161() == GPR_FAIL) jump Fail_1;
if (NextWordStopped() ~= 'baz') jump Fail_1;
...
];
[ Cond_Token_161 ;
if (((((scene_status-->(I126_bar-1)==1))))) return GPR_PREPOSITION; ! tests whether scene is active
return GPR_FAIL;
];
As you can see, the check for the when/while
causes the parse_name()
routine to decide on failure before the actual input is inspected for a match to the given word.
4 Likes
Thanks for the explanation otis.
-Wade