print function

Artur Skawina via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 5 06:33:17 PST 2016


On 02/05/16 14:38, Ola Fosheim Grøstad via Digitalmars-d-learn wrote:
> On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote:
>> call used to print diagnostics. What I saw made me never use or look at D's std lib again. Except for meta programing and toy/example programs where it doesn't matter.
> 
> What do you use instead? A buffer and Posix write() and aio_write()?

For ad-hoc temporary debugging usually a local wrapper

   @noinline writeln(A...)(A a) {
      import std.stdio;
      std.stdio.writeln(a);
   }

[the reason for @noinline is to not disturb the caller]
This is where the `print` function would be useful. It
could even be made to work at CT (w/ compiler help; this
has been a often requested feature).

For programs that output one or few text lines to stdout
(results, status updates etc) - `printf` -- it's already
there in libc anyway, so zero-cost and GC-free.

For everything else - the C/Posix functions.


artur


More information about the Digitalmars-d-learn mailing list