Jonathan M Davis wrote:
On Saturday 06 November 2010 07:42:52 Don wrote:
Michel Fortin wrote:
On 2010-11-05 21:32:47 -0400, Don <nos...@nospam.com> said:
The motivation for wanting to ban them is to prevent the optimiser
from generating bad code.
It seems to me that disabling pure optimizations inside 'static this()'
would be enough to prevent generating bad code. It's not like pure
optimizations cross function boundaries.
That's probably doable, if we largely abandon the idea that the return
value of a pure function can be cacheable. Which I think is a bit of a
fanciful idea anyway.

If they're not cacheable, what's the point of pure? I thought that that was the entire point.

I mean globaly cacheable.

You could avoid extra calls to the function by just re-using its
value - at least within the current expression if not the current function. I quite understand avoiding caching a result for the entire run of the program (if nothing else, that could use up a lot of memory),

Yes. And working out if a function is worth caching is a very difficult problem. I think the overhead would be so high, that it would almost never be a nett gain.

 but I thought that avoiding
extra function calls was the whole point of pure.

The guarantee of independence is the most important feature. From a performance point of view, the big win 'pure' gives you comes from memory management. All memory allocation can be done using a thread-local memory pool.

Reply via email to