Steven Schveighoffer <[email protected]> wrote:
Pure might be worth stuffing in the symbol name, as the compiler may
optimize things differently for pure vs. non-pure(dirty?) code.
E.g. the result of a large, pure function that takes a while to compute
might be cached to prevent calling it twice.
These are decisions made at the compilation stage, not the linking stage.
Absolutely. Now, you compile your module that uses a pure function foo in
another module, and the above optimization is used. Later, that module is
changed, and foo is changed to depend on some global state, and is thus
no longer pure. After compiling this one module, you link your project,
and the cached value is wrong, and boom! Nasal demons.
--
Simen