Nov 6, 2025

[software design][functional programming] Referential transparency

Referential transparency

An expression is referentially transparent if it can be replaced with its corresponding value without changing the program's behavior.

This means that for a function to be referentially transparent, it must be a pure function, which has two key properties:

  • It always returns the same output for the same inputs.
  • It has no side effects. (It doesn't modify global variables, print to the console, read from a file, make a network request, etc.)


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.