'pp' for D?
monarch_dodra
monarchdodra at gmail.com
Tue Oct 1 13:29:20 PDT 2013
On Tuesday, 1 October 2013 at 19:47:16 UTC, linkrope wrote:
> On Tuesday, 1 October 2013 at 07:30:06 UTC, Jacob Carlborg
> wrote:
>> On 2013-09-30 23:56, bearophile wrote:
>>
>>> Surely Phobos should add a prettyPrinting() function, like
>>> the function
>>> of Python standard library.
>>
>> I would rather have function that generates a pretty
>> representation of a given value. Then it either can be used to
>> print the representation or something else.
>
> How about "%r" in 'format'?
>
> Then for arrays, "%(%s, %)" would in fact be "%(%r, %)" while
> "%-(%s, %)" would in fact be "%(%s, %)" - breaking existing
> code; punishable by 'xxformat' for at least one year :-)
%r is already taken: It means "raw". It's used as a way to use
formatting, even when writing in a binary file. You can even use
"%+r" and "%-r" to specify the endian-ness you want to write in.
It's fun. Makes writing file headers *real* easy.
More information about the Digitalmars-d-learn
mailing list