Comment by WalterBright
4 days ago
D has a keyword prefix `debug`. So, one can write things like:
...
debug if (x) printf("x: %d\n", x);
...
So, you can throw the -debug switch on the compiler and the debug code is enabled. For asserts,
debug assert(lookMa);
and the check is only run when the -debug switch is done. It works remarkably well.
Another interesting property of `debug` is it turns off the safety checks in the target statement that follows it. Because, sometimes you just gotta do some unsafe tricks to figure out where your code went wrong.
No comments yet
Contribute on Hacker News ↗