Statement (computer science)

As instruction (English statement) is called in computer science, there in the field of programming, a key element of many imperative programming languages. The programs of such languages ​​consist primarily composed of one or more statements. A statement is a formulated in the syntax of a programming language single rule to be executed as part of the execution of the program. As an instruction has to look syntactically, is determined by the particular programming language or the specification and can not be changed within a program.

In the machine-level programming instructions are often called command (English instruction or command) designated.

Instructions are usually assignments, control statements ( such as jumps, loops and conditional statements) and procedure calls. Depending on the programming language are partly assurances, declarations, class and function definitions instructions.

Unlike expressions statements do not always have a value. However, some statements can be expressions, such as assignments, Inkrementoperatoren or function calls. Conversely, there are many types of expressions such as comparisons or arithmetic expressions not syntactically complete instructions.

Sequences of statements are often grouped in blocks.


See also Programming Language Elements


The appearance of a program is characterized by the appearance of the instructions. Therefore, programming languages ​​are often distinguished by the type of instructions (eg: languages ​​with braces ). Many statements begin with an identifier such as if, while, or repeat. Often the keywords of the instructions are reserved, so they can not be used as the name of a variable or function. Imperative programming languages ​​usually use a special syntax for their instructions, which clearly differs from a function call. Common methods to describe the syntax of statements are Backus -Naur Form and syntax diagram.


Semantically many instructions differ from subroutines by the treatment of their parameters. Normally, an actual parameter before calling the subroutine is evaluated. This is different from the parameters of many instructions, which are evaluated several times (eg, the condition of a while loop ) or not (eg the body of a while loop ). Technically, such a statement parameter Closures, which are executed when required (see also lazy evaluation ). If Closure parameters for subroutines are available, the behavior of an instruction can be implemented by subroutines (see Lisp ). Though the semantic description of a loop or conditional statement about the ability of language also for languages ​​without Closure parameters. That is why specifications often use semantic descriptions in natural language.