| for Windows Speech Recognition, by Rick Mohr | Home | Vocola 2 | Vocola 3 |
|
|
|
To understand why action evaluation is an important reference topic, consider these example commands:
|
Phrase Start = {Left_ String.Length(Dictation.Get()) }; Copy to WordPad = {Ctrl+c} SwitchTo(WordPad) {Ctrl+v}; |
"Phrase Start" moves the insertion point to the beginning of a just-dictated phrase. It works by calling Dictation.Get to retrieve the dictated phrase and String.Length to count its characters. The count is then concatenated between {Left_ and } to construct a keystroke specifier, such as {Left_15} for a 15-character phrase. For this command to work, String.Length must be called before any keystrokes are sent.
"Copy to WordPad" copies text to WordPad. It works by sending the keystroke {Ctrl+c} to copy text, calling SwitchTo to bring up WordPad, and sending the keystroke {Ctrl+v} to paste the text. For this command to work, SwitchTo must be called after the keystroke {Ctrl+c} is sent.
Clearly Vocola is evaluating actions differently for these two examples.
To explain action evaluation more formally we start with some definitions:
Essentially, the examples above work because Vocola calls value functions eagerly and action functions lazily.
Formally, Vocola identifies a value function as one that either:
Conversely, Vocola identifies an action function as one that either:
(See Function Attributes for a description of CallEagerly.)
We offer both an informal and a formal description of how action sequences are evaluated.
Actions evaluate to strings (possibly empty). Adjacent strings are concatenated.
Calls to value functions are evaluated eagerly; calls to action functions are evaluated lazily. Arguments to these native functions are evaluated before the call. Calls to user functions are simply unrolled.
To execute an action sequence, simplify the actions to atoms, combine the atoms, and then execute the atoms.
An atom is either:
To execute an action sequence:
To simplify an action, producing a sequence of atoms:
To evaluate an argument to a native function call:
(In the above discussion, the Repeat special form is treated as an action function.)