Walter:

> On the contrary, I think it is the right solution. After all, the reason 
> people
> want to put impure code in a pure function is for debugging. By putting it 
> under
> the debug conditional, any logging or printing code can be there without 
> needing
> the compiler to be aware of what they do.

(Extra note: logging not fully related to debugging. Large programs often keep 
logs even in release mode.)

There is something I don't understand. If your last change allows code like 
this, isn't it breaking the safety of pure functions in debug mode? Do you 
think this loss of safety is not important?


int some_global;

void loggit(int x) {
  some_global++;
  writeln(x);
}

pure nothrow int sqr(in int x) {
  debug loggit(x);
  return x * x;
}

Bye,
bearophile

Reply via email to