[r6rs-discuss] [OT] Should compilers preserve termination?

Mikael Tillenius mti at tillenius.com
Mon Mar 12 08:21:10 EDT 2007


Ludovic Courtès wrote:
> How would you notice that a side-effect-free loop has been optimized
> away?  I believe you can't.
>   
If it should loop more than, say 1e20 times, it is quite easy to notice 
whether it is optimized away or not;-) Especially infinite loops are 
easy to distinguish from no loop at all.

Actually, part of the problem is to define what a side effect is. 
Suppose I have a loop that allocates (and releases) memory with some 
pattern. It has no effect whatsoever on the meaning of the program but 
it can be quite useful to test the effectiveness of a garbage collection 
implementation. Similar things have been used to send messages between 
processes that were supposed to be totally isolated from each other. The 
way your operation system handles the essentially side-effect free "idle 
loop" when no processes are running is directly related to how long your 
laptop will run on battery.

But yes, we are getting off topic...

/Mikael




More information about the r6rs-discuss mailing list