# Strict function

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Strict_function
> Markdown URL: https://mediated.wiki/source/Strict_function.md
> Source: https://en.wikipedia.org/wiki/Strict_function
> Source revision: 985184858
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Refimprove|date=July 2016}}
In [computer science](/source/computer_science) and [computer programming](/source/computer_programming), a [function](/source/function_(computer_programming)) f is said to be '''strict''' if, when applied to a non-terminating expression, it also fails to terminate.<ref>{{Cite web|url=https://www.haskell.org/tutorial/functions.html|title=A Gentle Introduction to Haskell: Functions|website=www.haskell.org|access-date=2016-06-23}}</ref> A '''strict function''' in the [denotational semantics](/source/denotational_semantics) of [programming language](/source/programming_language)s is a [function](/source/function_(mathematics)) ''f'' where <math>f\left(\perp\right) = \perp</math>.  The entity <math>\perp</math>, called ''[bottom](/source/Bottom_type)'', denotes an expression that does not return a normal value, either because it loops endlessly or because it aborts due to an error such as division by zero.  A function that is not strict is called '''non-strict'''. A [strict programming language](/source/strict_programming_language) is one in which user-defined functions are always strict.

Intuitively, non-strict functions correspond to [control structure](/source/control_structure)s. Operationally, a strict function is one that always [evaluate](/source/evaluate)s its [argument](/source/parameter); a non-strict function is one that might not evaluate some of its arguments. Functions having more than one parameter can be strict or non-strict in each parameter independently, as well as ''jointly strict'' in several parameters simultaneously.

As an example, the <code>if-then-else</code> expression of many programming languages, called <code>[?:](/source/%3F%3A)</code> in languages inspired by C, may be thought of as a function of three parameters. This function is strict in its first parameter, since the function must know whether its first argument evaluates to true or to false before it can return; but it is non-strict in its second parameter, because (for example) <code>if(false,<math>\perp</math>,1) = 1</code>, as well as non-strict in its third parameter, because (for example) <code>if(true,2,<math>\perp</math>) = 2</code>. However, it is jointly strict in its second and third parameters, since <code>if(true,<math>\perp</math>,<math>\perp</math>) = <math>\perp</math></code> and <code>if(false,<math>\perp</math>,<math>\perp</math>) = <math>\perp</math></code>.

In a [non-strict](/source/non-strict_programming_language) [functional programming](/source/functional_programming) language, [strictness analysis](/source/strictness_analysis) refers to any algorithm used to prove the strictness of a function with respect to one or more of its arguments. Such functions can be [compiled](/source/compilation_(programming)) to a more efficient [calling convention](/source/calling_convention), such as [call by value](/source/call_by_value), without changing the meaning of the enclosing program.

== See also ==
* [Eager evaluation](/source/Eager_evaluation)
* [Lazy evaluation](/source/Lazy_evaluation)
* [Short-circuit evaluation](/source/Short-circuit_evaluation)

==References==
{{Reflist}}

{{DEFAULTSORT:Strict Function}}
Category:Formal methods
Category:Denotational semantics
Category:Evaluation strategy

---
Adapted from the Wikipedia article [Strict function](https://en.wikipedia.org/wiki/Strict_function) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Strict_function?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
