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:
“All orthodox opinionthat is, today, revolutionary opinion either of the pure or the impure varietyis anti-man.”
—Wyndham Lewis (18821957)
“Adolescents, for all their self-involvement, are emerging from the self-centeredness of childhood. Their perception of other people has more depth. They are better equipped at appreciating others reasons for action, or the basis of others emotions. But this maturity functions in a piecemeal fashion. They show more understanding of their friends, but not of their teachers.”
—Terri Apter (20th century)
“In verity, an independent world,
Created out of pure intelligence.”
—William Wordsworth (17701850)
“Its idea of production value is spending a million dollars dressing up a story that any good writer would throw away. Its vision of the rewarding movie is a vehicle for some glamour-puss with two expressions and eighteen changes of costume, or for some male idol of the muddled millions with a permanent hangover, six worn-out acting tricks, the build of a lifeguard, and the mentality of a chicken-strangler.”
—Raymond Chandler (18881959)