February 24, 2007
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! :-)
February 24, 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
February 24, 2007
renoX wrote:
> 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..)

I just answered this question in your thread "Re: "Hiding" the mixin keyword?" in d.D.learn.
For the people who don't want to go look it up:
-----
Looks like he hid the mixin() in a templated function call, using property syntax to remove the trailing ().
I'm pretty sure that means he can't support variables in the initializers, nor expressions containing variables.
It would seem these are quite important for a (runtime) string formatter though. ;)
-----
1 2
Next ›   Last »