Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Strict function

From Wikipedia, the free encyclopedia
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Strict function" – news ·newspapers ·books ·scholar ·JSTOR
(July 2016) (Learn how and when to remove this message)

Incomputer science andcomputer programming, afunction f is said to bestrict if, when applied to a non-terminating expression, it also fails to terminate.[1] Astrict function in thedenotational semantics ofprogramming languages is afunctionf wheref()=⊥{\displaystyle f\left(\perp \right)=\perp }. The entity{\displaystyle \perp }, calledbottom, 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 callednon-strict. Astrict programming language is one in which user-defined functions are always strict.

Intuitively, non-strict functions correspond tocontrol structures. Operationally, a strict function is one that alwaysevaluates itsargument; 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 asjointly strict in several parameters simultaneously.

As an example, theif-then-else expression of many programming languages, called?: 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)if(false,{\displaystyle \perp },1) = 1, as well as non-strict in its third parameter, because (for example)if(true,2,{\displaystyle \perp }) = 2. However, it is jointly strict in its second and third parameters, sinceif(true,{\displaystyle \perp },{\displaystyle \perp }) ={\displaystyle \perp } andif(false,{\displaystyle \perp },{\displaystyle \perp }) ={\displaystyle \perp }.

In anon-strictfunctional programming language,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 becompiled to a more efficientcalling convention, such ascall by value, without changing the meaning of the enclosing program.

See also

[edit]

References

[edit]
  1. ^"A Gentle Introduction to Haskell: Functions".www.haskell.org. Retrieved2016-06-23.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Strict_function&oldid=985184858"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp