Impure Functions in Pure Expressions
The definitions above still allow some laxity with regard to purity. It is possible for a pure expression to yield an impure function (or more generally a value which contains one or more impure functions).
It is also possible for an expression to be pure even if one or more of the argument subexpressions yields an impure function (or a value which contains one or more impure functions). In this case the impure function(s) in the argument must not be applied during evaluation (but may be incorporated in the result somehow). However, dealing with programs that allow impure and pure functions to be mixed like this can be quite difficult in practice, thus purely functional programming languages do not allow impure functions to be defined. Effect systems, among other things, allow one to reason precisely and formally about the purity of certain expressions even in the presence of higher-order functions etc.; they even allow to prove that a certain function does not have any side effects although it uses impure operations (for example, uses a mutable array for computation internally, but does not expose it to the outer world or maintain its state between invocations).
Read more about this topic: Pure Function
Famous quotes containing the words impure, functions, pure and/or expressions:
“The authority of government, even such as I am willing to submit to,for I will cheerfully obey those who know and can do better than I, and in many things even those who neither know nor can do so well,is still an impure one: to be strictly just, it must have the sanction and consent of the governed. It can have no pure right over my person and property but what I concede to it.”
—Henry David Thoreau (18171862)
“If photography is allowed to stand in for art in some of its functions it will soon supplant or corrupt it completely thanks to the natural support it will find in the stupidity of the multitude. It must return to its real task, which is to be the servant of the sciences and the arts, but the very humble servant, like printing and shorthand which have neither created nor supplanted literature.”
—Charles Baudelaire (18211867)
“If an opinion can eventually go to the determination of a practical belief, it, in so far, becomes itself a practical belief; and every proposition that is not pure metaphysical jargon and chatter must have some possible bearing upon practice.”
—Charles Sanders Peirce (18391914)
“The expressions of the poet cannot be analyzed; his sentence is one word, whose syllables are words. There are indeed no words quite worthy to be set to his music. But what matter if we do not hear the words always, if we hear the music?”
—Henry David Thoreau (18171862)