template statistics
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Jun 5 21:07:26 UTC 2020
On Fri, Jun 05, 2020 at 08:41:53PM +0000, Adam D. Ruppe via Digitalmars-d wrote:
> On Friday, 5 June 2020 at 20:10:30 UTC, Andrei Alexandrescu wrote:
> > It would be great if someone took a look at that.
>
> Yeah, this is why when reducing bugs I often prefer to use `printf` or
> even `assert(0)` or `asm { int 3; }` since it does result in a lot
> less code generated.
I guess YMMV and all that, but I find all the "unnecessary
complications" of writefln eminently useful when debugging, esp. with
the %(...%) format specs that can print ranges and can be nested. Very
useful for one-line, throwaway debug dumps of range contents that
doesn't require writing an entire function and range-interpretation
framework just to get some miserable debug output, like you need to in
C. With write(f)ln's "complications", you can just write a 1-line debug
dump that you throw away after the next code-compile-debug cycle without
thinking twice.
> BUT, in the context of a regular program, I caution against making too
> big a deal of this. Yes, there's more code than there needs to be *for
> this simple case*, but much of it exists to support real world code
> that is more complicated out of necessity.
Yes, we're blowing so much steam over a measly hello world program when
larger, much more important issues lie unsolved. Typical bikeshed vs.
nuclear reactor situation. :-D
> People don't actually write "hello world" programs. It'd be amusing to
> have the compiler recognize the input pattern and output some
> hand-tuned perfectly assembly for it.... but it'd also be useless.
[...]
Even more amusing would be for the compiler to recognize the pattern,
and launch a browser to some tutorial page on dlang.org explaining next
steps to go after your hello world program runs. :-P
But yeah, also equally useless.
T
--
The peace of mind---from knowing that viruses which exploit Microsoft system vulnerabilities cannot touch Linux---is priceless. -- Frustrated system administrator.
More information about the Digitalmars-d
mailing list