Literal (computer programming)
A literal is a special part of a formal language.
Literals in programming languages
As literal (Latin littera, letter ' ) is referred to in programming a string that is defined for the direct representation of the values of basic types (eg integers, floating point numbers, strings) or permissible.
A distinction is logical ( true, not true), numeric and character literals. Depending on the programming language provides further and more detailed categorizations for literals. This literals can be identified by the compiler, they must satisfy certain syntactic rules, such as his (language-dependent, and in certain cases) enclosed in quotes.
Literals as part of commands are also referred to as literal constants or named constants, since both literals and constants for the duration of the program are immutable. Literals are allowed in assignment operators only as a send expression (usually on the right side; ' rows = 60'), are encoded as an argument to a function or as the value of a constant.
Also functions can be written as literals in functional programming. These are called anonymous functions or lambda functions.
Similar to the Literalbegriff know some programming so-called " figurative constants". These are (eg in Cobol ) acc. " COBOL words are generated [ different spellings, such as in plural form ] for the particular compiler values ": Zero, Space, High-Value and Low -Value ratio and 'ALL literal '.
As an aspect of programming style is recommended in part to use in the command part of the program code not possible literals, but substitute constants that any can be addressed in the source code often - instead of always using the same literal. This provision should lead to greater transparency and ease of maintenance.
Examples of literals
Literals in mathematical logic
In mathematical logic, a literal is an atomic statement (Atom) or the negation of an atomic statement. It has therefore been positive literals and negative literals. A disjunction of literals is called Disjunktionsterm or as a clause.