Referential Transparency

你。 提交于 2019-12-04 05:30:43

As you might know, the term "referentially transparent" means that the value of expression can depend only on the values of its parts, and not on any other facts about them.

For example, it cannot depend on the following:

  • Whether some part of expression is already evaluated or not (in a lazy language)
  • Whether two equal values are shared (are pointers to the same location in memory) or not
  • Whether a data structure is cyclic (i.e. its pointers create a cycle) or not

All those facts about the current state of the program are either true or false, but no expression can change its value depending on them. So those things are called non-observable.

This webcomic and its discussion on reddit might enlighten you as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!