Referential Transparency

Noun · Development

Definitions

  1. A property of expressions where they can be replaced with their value without changing program behavior. A function is referentially transparent if calling it with the same arguments always returns the same result and has no side effects. The foundation of functional programming's reasoning model.

    In plain English: When a function always gives the same answer for the same inputs and doesn't change anything else — you can swap the call for its result.

    Example: "add(2, 3) is referentially transparent — you can replace it with 5 anywhere. getCurrentTime() is not, because it returns different values each call."

Related Terms