Unused import tool
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Fri Aug 18 17:11:19 UTC 2023
On 19/08/2023 5:00 AM, Walter Bright wrote:
> I ask that `import core.stdc.stdio;` stop being regularly deleted, as I
> regularly add it back in. dmd uses printf all over the place for debug
> information.
This is sounding an awful lot like the import should be done where it is
used and a dedicated log functions should be implemented.
I quite often do something like:
```d
version(none) {
debug {
try {
import std.stdio;
writeln("...");
stdout.flush;
} catch (Exception) {
}
}
}
```
I.e.
https://github.com/Project-Sidero/basic_memory/blob/main/source/sidero/base/text/internal/builder/operations.d#L1199
Also add random debug blocks to do extra verification:
https://github.com/Project-Sidero/basic_memory/blob/main/source/sidero/base/text/internal/builder/operations.d#L783
Both ``version(none)`` and ``debug`` blocks are absolutely amazing tools
for dealing with debug only code that shouldn't see production!
Very helpful for when I come back to complex code after many months or
years and hitting segfaults if you catch my drift ;)
More information about the Digitalmars-d
mailing list