# DiGrande.it

Blind, Braille and Embossing Technologies

This site uses cookies to personalize content and ads, provide social media features and analyze links. By closing this banner or continuing to browse, you consent to their use.

# Blocks, short circuits and interpretation index

One or more instructions can be enclosed within round brackets "(...)" that delimit a block. Enclosing instructions in blocks is useful for evaluating the end result of the instructions in the block, not the individual results of each instruction. For example:

- A & B | C - The expression is true if A is true and B is true, or C is true. The evaluation of the expression stops if A and B are true, otherwise it continues by analyzing C. Also if A is false the analysis stops with false as well.

- A & (B | C) - The expression is true if A is true and B or C is true. Evaluation of the expression stops if A is false, or continues by entering the instruction block, evaluating B, stopping if B is true, or continuing with the evaluation of C.

THE SHORT CIRCUIT

If logical operators are used explicitly, expressions are interpreted using the SHORT CIRCUIT technique. This means that if the part already interpreted provides a value that is useful to satisfy the whole expression, the part to be interpreted will be ignored and the circuit will end. For example:

- A | B - If A is true, B is not evaluated, since the expression would give a true result anyway.

- A & B - In this case both A and B must have a true value to satisfy the expression, so the whole expression is evaluated if A is true. Otherwise, if A is false, it breaks, since even evaluating B would still result in the expression being false.

SHORT CIRCUIT AND IMPLICIT "AND"

In expressions where you don't explicitly specify the & (AND) operator, short-circuiting is not applied. For example:

- A B - The expression is evaluated in both A and B, even though A is false. At the end if A and B are true the expression will be true.

- A & B - In this case we explicitly used AND operator. If A is false B is not evaluated, because it activates the short circuit which considers the expression false anyway.

SHORT CIRCUIT AND FLAG INSTRUCTIONS

Biblos language has special instructions (flag and index) which, when executed, perform specific actions. These instructions are executed only if they are reached by the expression interpreter. Since they are instructions contained in the same line of code to be interpreted, the short-circuit system may prevent their execution.

If flag or index shift instructions are used, it is useful to use parentheses to enclose the instructions to be parsed by short-circuiting, and to put the flag or index instructions outside the parentheses.

ANALYSIS INDEX AND INSTRUCTIONS

Consider that Biblos parses text using an index variable. Instructions satisfy their conditions (true or false) by reading the text through this special variable. In many instructions you have to specify values. The instruction will use the index variable to check if this value satisfies the text where the index is located. Each instruction always returns a unary Boolean value (true or false). It will return true if text and value satisfy, false otherwise.