Improvement of format string. Re: Suggestion for a D project/std module: templated format

renoX renosky at free.fr
Sat Feb 24 00:11:49 PST 2007


Miles a écrit :
> renoX wrote:
>> Below is a sample implementation (could be used as a basis for
>> "templated format" if wanted), it is lacking the possibility to have
>> %08d{} but this could be added..
> 
> Nice! :-)

There's a better implementation under 'Improvement on format strings, 
take two': it works with things like %08d{x+y} (and any legal format 
string between %..{ ), and has no problem with non-const char[] (it just 
leave them alone).

But there are remaining problems:
-you need to call it like: mixin(putf!(...));
the mixin keyword doesn't look nice, and when there is a problem at 
compile time (I dont' undestand why it's needed: Reiner Pope in 'Mixin 
demo: associative array initializers' manage to hide it him..)

- the line given for the error is inside the template processor, and I 
haven't found any way to show the line where the call is made: for a 
developer this is not easy to debug when he makes an error in the format 
string.

And lastly the implementation could probably be improved, but that's 
normal: I'm a beginner in D..

renoX



More information about the Digitalmars-d mailing list