The sad state of textual representation in D

Fractal email at server.com
Mon Jun 8 17:26:54 PDT 2009


bearophile Wrote:

> The printing functions of Tango are nearly trash for me, I don't like how they are imported, the structure of the hierarchy where they are collocated in modules/packages, their duplication, their name, their API and usage. They are also unsafe. (C std.c.stdio.printf is better, cleaner, simpler, and it seems about equally unsafe, but it's much faster and produces smaller exes).
> 
> The printing functions used by Phobos2 are a bit better, but they print very *badly* a wide variety of things, and so far Walter&Co have shown no/little interest in improving them a LOT. Its name (writefln, writef, write, writeln) is much long still, and in the beginning for me it was easy to write "writelnf" instead of "writefln".
> I have shown here both the many faults/limits of those writefln-like functions (and I can show again about 20-30 groups of situations where they print in an ugly or wrong way), and I have offered a (partial and probably far from perfect = it has bugs) implementation of put/putr that look quite better, despite being ignored.
> 
> I think the current situation of printing functions in D is a mess. The only tiny improvement I have seen so far in this topic is the introduction of write/writeln in Phobos2, that help avoid a bad bug that happens in D1 (it has actually happened to me two times) if for mistake the first argument of writefln is a string that contains a % that you didn't know about. On the other hand I think the printing of AAs in Phobos2 is worsened compared to D1, I don't remember if this bug was fixed in the meantime.
> 
> Saying that printing is not important is wrong, because when you print something even just for debugging you want a clear, nice, readable and as little ambiguous output as possible. Most of the programs I write print data on the console or in textual files, and I usually can't use the writefln/writef, because they have too many problems.
> 
> Bye and sorry for being a bit nervous about this topic,
> bearophile

Thanks bearophile for your response... please tell me what you think about a new API

Fractal



More information about the Digitalmars-d mailing list