Strict semantics: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
(As opposed to [[non-strict semantics]].) | |||
In programming languages that use strict semantics, an undefined argument of a function leads to an undefined function result. This happens even if the argument's value isn't needed by the function: | |||
<pre> | <pre> | ||
∀ f . f undefined = undefined | ∀ f . f undefined = undefined | ||
</pre> | </pre> | ||
As a result, the <code>if ... then ... else ...</code> conditional usually requires additional support from such languages to work correctly - evaluate the condition, then the selected alternative (<b>not</b> both of them). | |||
It may be implemented by [[eager evaluation]]. Examples of programming languages which use strict semantics include [[OCaml]] and LISP. | It may be implemented by [[eager evaluation]]. Examples of programming languages which use strict semantics include [[OCaml]] and LISP. | ||
[[Category:Glossary]] | [[Category:Glossary]] |
Latest revision as of 05:45, 1 January 2025
(As opposed to non-strict semantics.)
In programming languages that use strict semantics, an undefined argument of a function leads to an undefined function result. This happens even if the argument's value isn't needed by the function:
∀ f . f undefined = undefined
As a result, the if ... then ... else ...
conditional usually requires additional support from such languages to work correctly - evaluate the condition, then the selected alternative (not both of them).
It may be implemented by eager evaluation. Examples of programming languages which use strict semantics include OCaml and LISP.