Pure Expressions
Pure functions are required to construct pure expressions. Constant expressions are pure by definition. An expression consisting of a function subexpression applied to one or more argument subexpressions is pure if both these statements about the subexpressions hold:
- The function and argument subexpressions are pure expressions.
- The function subexpression yields a pure function.
Typically the function subexpression is simply a function identifier. Pure expressions are often referred to as being referentially transparent.
Evaluation of a given pure expression will yield the same result regardless of when or how many times evaluation occurs during program execution. This property is what makes it meaningful to talk about an expression's "value". It also makes it possible to replace an expression with the corresponding value (or it with an equivalent alternative expression) without changing the meaning of a program.
Read more about this topic: Pure Function
Famous quotes containing the words pure and/or expressions:
“A mans social and spiritual discipline must answer to his corporeal. He must lean on a friend who has a hard breast, as he would lie on a hard bed. He must drink cold water for his only beverage. So he must not hear sweetened and colored words, but pure and refreshing truths. He must daily bathe in truth cold as spring water, not warmed by the sympathy of friends.”
—Henry David Thoreau (18171862)
“Many expressions in the New Testament come naturally to the lips of all Protestants, and it furnishes the most pregnant and practical texts. There is no harmless dreaming, no wise speculation in it, but everywhere a substratum of good sense. It never reflects, but it repents. There is no poetry in it, we may say, nothing regarded in the light of beauty merely, but moral truth is its object. All mortals are convicted by its conscience.”
—Henry David Thoreau (18171862)