"renoX" <reno...@free.fr> wrote in message news:49f56a74.4000...@free.fr... > Nick Sabalausky a écrit : >> "bearophile" <bearophileh...@lycos.com> wrote in message >> news:gsipn1$1bn...@digitalmars.com... >>> Andrei Alexandrescu: >>>> If it were an error, I wouldn't let it go. >>> It's an error. It will lead to troubles. >>> >> >> Sometimes it is an error, but there are times when it isn't: > [cut] >> Call List In Psuedo-Japanese: >> For Each Person Where Name="Smith": "SmithSan {LoopIndex}'s DenwaBango: >> {Phone}" >> --------------------- >> >> So then the report creation code: >> >> --------------------- >> foreach(int i, Person p; people.subset(customReport.whereClause)) >> writefln(customReport.formatStr, i, p.id, p.first, p.last, p.phone, >> p.zip); >> --------------------- >> >> That would be very difficult/limiting if every arg had to be used in the >> format string. > > Mmmh, is {LoopIndex} correct? It should be {i} I think and I would argue > that this format string should generate an error (something better than a > runtime exception would be nice but I'm not sure that this is possible). >
That was just for illustrative purposes. > >> (Incidentally, this example also demonstrates why I consider >> C#/Tango-style string formatting superior to C/Phobos-style) > > I think that named format string are much superior to positional format > string as they are easier to read/write.. > Actually, I was referring to the ability to specify them out-of-order, repeat them, etc. (I didn't realize that Phobos's writef had recently gained that ability). To my knowledge, C#/Tango string formatting don't actually support named strings, only numerical ones. I was just using names for illustrative purposes, and (unclearly) implying that the app would translate those named formats into numerical ones before passing them along to the string output function.