Two standard libraries?

Don Clugston dac at nospam.com.au
Sat Jul 14 15:05:32 PDT 2007


Jarrett Billingsley wrote:
> "Jason House" <jason.james.house at gmail.com> wrote in message 
> news:f7atnl$2lm6$1 at digitalmars.com...
>> Out of curiosity, why is {} used instead of %s?
> 
> It makes it easier to make more flexible formatting, and also so you can put 
> indices into the braces.  Indexing the arguments is important because word 
> order in different languages can be different.  For example, say you had the 
> message in English:
> 
> "Employee {} is not in personnel database {}", personName, databaseName
> 
> Now look at a language like Japanese, where you'd probably put the database 
> name first; it'd be arranged something like "in personnel database {}, 
> employee {} does not exist".  Now you have to change the order of the 
> arguments after the format string.  But with indexing, you can say {0} 
> always is the employee name, and {1} always is the database name, so that 
> you can format them in the correct order for other languages, without having 
> to change the actual format code.  Just change the format string.

That's a great argument -- I think it deserves to be in the Tango docs. It's 
surely a frequently asked question from programmers with a C/C++/Phobos background.



More information about the Digitalmars-d mailing list