August 18
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.
August 19
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 ;)
August 20
On Friday, 18 August 2023 at 17:00:33 UTC, 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.

I haven't deleted any core.stdc.stdio imports in the PRs that have been enabled by the tool (even though the tool correctly reported those as being unused).
August 20
On 8/20/2023 4:43 AM, RazvanN wrote:
> I haven't deleted any core.stdc.stdio imports in the PRs that have been enabled by the tool (even though the tool correctly reported those as being unused).

Thank you.
August 20
On 8/18/2023 10:11 AM, Richard (Rikki) Andrew Cattermole wrote:
> I quite often do something like:
> 
> ```d
> version(none) {
>      debug {
>          try {
>              import std.stdio;
>              writeln("...");
>              stdout.flush;
>          } catch (Exception) {
>          }
>      }
> }
> ```

In the dmd source code, there are a lot of commented out printf's. There would be a lot of clutter if an import statement had to be added for each of them.

August 21

On Sunday, 20 August 2023 at 16:17:34 UTC, Walter Bright wrote:

>

In the dmd source code, there are a lot of commented out printf's. There would be a lot of clutter if an import statement had to be added for each of them.

To be fair, these are terrible: like half of them don't work, because the variables involved have been renamed or removed entirely. Something like debugPrintf("...", args) that compiled to a no-op in release mode would be a lot better, and also avoid the "unused import" problem, no? Maybe even debugPrintf!"semantic2"("...", args), or alias debugPrintf = debugPrintf!"semantic2" at the top.

August 21
On 8/21/2023 3:45 AM, FeepingCreature wrote:
> To be fair, these are terrible: like half of them don't work, because the variables involved have been renamed or removed entirely.

I run across that now and then, and fix them. It's not been a significant problem.

> Something like `debugPrintf("...", args)` that compiled to a no-op in release mode would be a lot better, and also avoid the "unused import" problem, no? Maybe even `debugPrintf!"semantic2"("...", args)`, or `alias debugPrintf = debugPrintf!"semantic2"` at the top.

I did things like that for a while, and finally reverted to the stupid simple approach of printf.

August 22

On Tuesday, 22 August 2023 at 01:54:48 UTC, Walter Bright wrote:

>

On 8/21/2023 3:45 AM, FeepingCreature wrote:

>

To be fair, these are terrible: like half of them don't work, because the variables involved have been renamed or removed entirely.

I run across that now and then, and fix them. It's not been a significant problem.

Man, you wrote the thing, it's not surprising it isn't a problem for you! :)

If sc is gone, and now there's some other classes you haven't heard of, that may be subclasses of scopes or contain various numbers of scopes, good luck guessing. printf isn't just for debugging, it's also for learning how the compiler is supposed to do things; that gets more difficult if you have to guess which member is the right one to pay attention to.

Idk, simplification is good, but maybe I'd just have chucked a global alias printf = printfNoOp; in or something.

1 2
Next ›   Last »