Strict function

In computer science, a unary function is called strict if and only if its argument is undefined (, bottom ), the function result is also undefined. So if: . A multi-digit function may be strictly each in separate arguments or in all arguments. If all arguments are strict, then the function is strict.

Example

In Haskell defined functions are non-strict by default, but there's strictness annotations, with which you can mark individual arguments as strictly. For example, returns the following Haskell program:

{ - # OPTIONS - XBangPatterns # -}   bottom = undefined   f a b = a f ' a! b = a   main = do    print $ f [ 1,2,3 ] bottom    print $ f ' [1,2,3 ] bottom The following output:

[1,2,3]   strict: Prelude.undefined In the example, the function and the function is strictly non-strict.

Non - strict functions in strict programming languages

A programming language is referred to as strictly if defined functions are standard strictly. In programming languages ​​with lazy evaluation, individual functions are often predefined, which are non- strictly evaluated.

For example, contain imperative programming languages ​​such as Java or C the logical - OR operator (ie, a binary function in infix notation) that is non-strict evaluation:

Byte a; boolean b = ( a == 0 | | 1 / a> 0); If a is here equal to 0, so the rear part of the expression is not evaluated. Had the Or (| |) strictly here, it would b undefined if a would be equal to 0. This type of evaluation is also called short-circuit evaluation.

In functional programming languages ​​with lazy evaluation, the if -then-else function must be non- strictly defined so that any recursion (which contains an if - expression) can be programmed. In pseudo-code, the pattern matching is used:

- Condition expr1 expr2 if_then_else   expr1 expr2 expr1 = True if_then_else expr1 expr2 expr2 = False if_then_else evaluation strategy

Depending on which evaluation strategy uses a functional programming, functions are defined by default strict or non-strict. For example, the analysis strategy left-most/innermost-first to strict functions. The analysis refers to the selection of a reducible expression ( reducible expression, Redex ) in a functional expression which is not in normal form. The normal form is when the expression is Redex free and the execution of a functional program corresponds to the transfer of the program in the normal form. The innermost, first evaluation is referred to as strict evaluation. Intuitively, this corresponds to the procedure that the arguments of a function before the function call are evaluated ( and not just when they are needed ).

751902
de