On Wed, 25 Aug 2010 11:36:24 -0400, Simen kjaeraas <[email protected]> wrote:

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.

You could say the same about just about any function. Changing implementation can be a bad source of stale object errors, I've had it happen many times in C++ without pure involved at all. Moral is, always recompile everything :)

My point is just that name mangling was done to allow overloaded functions of the same name be linked by a linker who doesn't understand overloading. If pure functions cannot be overloaded on purity alone, then there's no reason to mangle purity into the symbol.

But it's a moot point, since purity *is* mangled into the symbol name.

-Steve

Reply via email to