Implementing std.log

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon May 9 12:47:05 PDT 2011


On 5/9/11 1:34 PM, Robert Clipsham wrote:
> On 09/05/2011 19:18, Andrej Mitrovic wrote:
>> I'm not a big fan of that format syntax. It's just hard to look at and
>> figure out what went wrong when things do go wrong.
>>
>> I'd prefer something like:
>> https://gist.github.com/963027
>>
>> But someone would have to implement it, of course. I have my own
>> little echo() function which takes simple "{}" positional syntax, it
>> doesn't have any other formatting options though. But I only ever need
>> formatting for simple cases like the above. It seems some people need
>> a whole word processor macro language embedded in a format string..
>
> That is A LOT nicer to look at. Please can we have this? :<

I, too, prefer it a great deal to the prinf/scanf format, and it 
wouldn't be difficult to implement, but at this point we need to worry 
about compatibility issues and such (TDPL already uses the % syntax as 
does existing D code). I don't see a simple migration path.

One possibility is to provide a nice2ugly template that transforms C# 
format strings into % format strings, e.g. nice2ugly!"{1}:{2}" yields 
the string constant "%1$s:%2$s".

By and large this doesn't seem to be a very worrisome issue as 
formatting strings are a minority in most applications and are seldom 
maintained. You pay attention, get them right, and then just use them.


Andrei



More information about the Digitalmars-d mailing list