Skip to content

Pure function

在阅读infogalactic Compile time function execution 时,其中有这样的描述:

the function does not make any reference to or attempt to modify any global state (is a pure function).

在 infogalactic Functional programming#Pure functions 中也有关于pure function的说明。

infogalactic Pure function

In computer programming, a function may be considered a pure function if both of the following statements about the function hold:

1) The function always evaluates the same result value given the same argument value(s).

2) Evaluation of the result does not cause any semantically observable side effect or output