Implementing std.log

Robert Clipsham robert at octarineparrot.com
Mon May 9 15:10:03 PDT 2011


On 09/05/2011 20:47, Andrei Alexandrescu wrote:
> On 5/9/11 1:34 PM, Robert Clipsham wrote:
>> 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
>

Compilation switch maybe? Support both by default, compile with 
-version=DisableUglyFormatStrings to remove the overhead. Document it as 
deprecated, tweak the first revision of TDPL to use the new format 
strings, give it <X> amount of time, make it deprecated etc. Having 
nice2ugly!"" all over my codebase is not a solution.

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d mailing list