operator and (operand1, operand2: Boolean) = Result: Boolean;
or
operator and (operand1, operand2: integer_type) = Result: integer_type;
or
procedure and (var operand1: integer_type; operand2: integer_type);
In GNU Pascal, and has three built-in meanings:
By default, and acts as a short-circuit operator in GPC: If the first operand is False, the second operand is not evaluated because the result is already known to be False. You can change this to complete evaluation using the --no-short-circuit command-line option or the {$B+} compiler directive.
The logical and operator is defined in ISO 7185 Pascal.
According to ISO, you cannot rely on and being a short-circuit operator. On the other hand, GPC's default behaviour does not contradict the ISO standard. (See and_then.) However, since it seems to be a de-facto standard among ISO Pascal compilers to evaluate both operands of and, GPC switches to --no-short-circuit mode if one of the language dialect options selecting ISO Pascal, for instance --extended-pascal, is given. Use --short-circuit to override.
Use of and as a bitwise operator for integers is a Borland Pascal extension.
Use of and as a “procedure” is a GNU Pascal extension.
program AndDemo; var a, b, c: Integer; begin if (a = 0) and (b = 0) then { logical `and' } c := 1 else if (a and b) = 0 then { bitwise `and' } c := 2 else and (c, a) { same as `c := c and a' } end.
Note the difference between the logical and and the bitwise and: When a is 2 and b is 4, then a and b is 0. Beware: a and b = 0 has nothing to do with (a = 0) and (b = 0)!
Since bitwise and has a higher priority than the = operator, parentheses are needed in if (a = 0) and (b = 0) because otherwise 0 and b would be calculated first, and the remainder would cause a parse error.