January 2020
Intermediate to advanced
470 pages
11h 13m
English
In mathematics, referential transparency is the property that lets you replace an expression with its value without changing the results of whatever you were doing.
To give a simple example, let's consider what happens with an optimizing compiler that performs constant folding. Suppose you have a sentence like this:
const x = 1 + 2 * 3;
The compiler might optimize the code to the following by noting that 2 * 3 is a constant value:
const x = 1 + 6;
Even better, a new round of optimization could ...