side-effect-free function

noun
UK /saɪd ɪˈfekt friː ˈfʌŋkʃən/
US /saɪd ɪˈfekt friː ˈfʌŋkʃən/

A side-effect-free function is a helper that gives you an answer without changing anything else.

Because add is a side-effect-free function, calling it never changes the numbers you pass in.


OTHER MEANINGS

2. In functional programming, a function whose output depends only on its inputs and which performs no observable actions.

The compiler can safely reorder calls to a side-effect-free function.

3. A routine that does not modify global state, I/O, or its arguments.

Reviewers flagged the logger call because it made an otherwise side-effect-free function impure.

4. A mathematical-style mapping used in testing where repeated calls yield identical results.

Property tests rely on the parser being a side-effect-free function.