Downloads Products Documents Community

Evaluating Command Blocks

Updated 1-Jan-2016/23:55:29

Scheduled for R3 A100 release.


There's a new high-speed method of evaluating external commands. Although created to evaluate graphics rendering commands, it can be used for any external sequence of commands that require maximum speed (e.g. high speed math processing such as FFTs, image processing, audio processing.)

Special Evaluation Method

The greater speed of command blocks is obtained through the use of a special evaluation method:

Why is it Useful?

In subsystems like the R3 GUI, graphical elements are rendered by generating semi-static draw blocks either during style definition (definition of a button), face instantiation (creating an instance of a button), or face state modification (eg. hovering over a button).

The advantage of the static form of such draw blocks is that they require no further evaluation, hence take no additional memory or CPU time. In fact, the state of the GUI at any specific time is simply a sequence of draw block renderings. Therefore, a fast method of calling draw functions can greatly speed-up the rendering time of the GUI.

For special draw dialects (like the one used in the GUI) where optional or datatype-ordered arguments are allowed, a conversion from the dialect block to the command block is required. However, this conversion was already being performed in order to reduce the run-time overhead of the dialects (to avoid the NxM argument reordering penalty), so no additional overhead is incurred.

General Form

The general form is:

do-commands [
    command1 arg11 arg12
    command2 arg21 arg22 arg23
    result: command3 arg31

Notice that set-words for results are allowed. In addition, the result of the final command will be returned from the do-commands function.

Note: If you can think of a better name than do-commands let Carl know.

Argument Requirements

Command blocks are written in a reduced minimal form. They consist of one or more commands followed by their arguments. The arguments must be actual values or variables; sub-expressions and operators are not allowed. If necessary, use reduce/only or compose to preprocess command blocks.

For example, you can write:

line 0x0 100x100
line 100x100 200x200

and the command can also be variables:

line start1 end1
line start2 end2

Sub expressions are not allowed:

line 0x0 base + 10   ; error
line 0x0 add base 10 ; error

However, if necessary you can escape to parens for sub-expressions, but it reduces run-time performance:

line 0x0 (base + 10) ; ok, but slow


An error will occur if any value other than a command is found:

multiply 10 20
** Script error: expected command! not multiply

An error will also occur if an argument is not of the correct datatype, or if the block ends before all of its actual arguments are provided.

About | Contact | Support | Privacy | LicenseREBOL Technologies 2016