Semantics of toString

Leandro Lucarella llucax at gmail.com
Fri Nov 6 05:38:52 PST 2009


Yigal Chripun, el  6 de noviembre a las 14:23 me escribiste:
> >>the c style format string that specifies types is a horrible horrible
> >>thing and should be removed.
> 
> >How do you do %.3f in {}-notation?
> 
> writefln("{0:F3}", value);
> 
> >Your formatting string should be written as writeln(ansi, " ", iso);

This is horrible, horrible for internationalization, you just can't assume
how a language order words.

Anyway, about the type in the format, I think it's nice, as you just
proved, tango have it too "{0:F3}" is saying "treat the value as a float
and format it that way". The deal is, the type should not be used to know
the size of the parameter in the stack like in C's printf(), it should be
just a hint to convert the value to another type.

So, type specification is important. Variables reordering is important
too, and you even have it in POSIX's printf():

	printf("%1$d:%2$.*3$d:%4$.*3$d\n", hour, min, precision, sec);

(see http://www.opengroup.org/onlinepubs/9699919799/functions/printf.html)

I like printf()'s format (I don't know if it's just because I'm used to it
though :).

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
"All mail clients suck. This one just sucks less." -me, circa 1995



More information about the Digitalmars-d mailing list