option -ignore_pure for temporary debugging (or how to wrap an unpure function inside a pure one)?

Timothee Cour thelastmammoth at gmail.com
Thu Feb 8 03:29:54 UTC 2018


while hacking into druntime and adding temporary debug information (eg
with custom logging etc) I had a hard time making things compile
because lots of functions are pure nothrow safe, resulting in compile
errors when my custom debugging functions are not pure nothrow safe.


How about adding flags ` -ignore_pure` (and perhaps -ignore_safe
-ignore_nothrow) to allow code to compile ignoring safe, pure, nothrow
mismatches?

This would be meant for temporary debugging obviously, production code
would not enable these flags.

my workaround for nothrow and safe attributes is to call via wrapNothrow!fun:

@trusted
nothrow auto wrapNothrow(alias fun, T...)(T a){
  import std.exception;
  try{
    return fun(a);
  }
  catch(Exception t){
    assert(0, t.msg);
  }
}

What would be a workaround to wrap a non-pure function?


More information about the Digitalmars-d mailing list