DIP9 -- Redo toString API
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Thu Nov 18 23:27:07 PST 2010
On Thu, 18 Nov 2010 17:21:20 -0500, Steven Schveighoffer wrote:
> I just created a new D Improvement Proposal to fix the toString problem
> I brought up several posts ago.
>
> See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9
I think it's best to leave out the '%' from the format string, like Don
has done with BigInt. This will facilitate the use of positional
parameters, in which the percent is followed by a position specifier
which necessarily has to be handled at a higher level than writeTo/
toString. Example:
writefln("%2$s, %1$s!", "World", "Hello");
It's not clear from the DIP whether this is what you intended, so I think
it should be specified.
Other than that, I think this proposal looks solid. What's cool about
this, apart from the performance benefits, is that it allows custom
format specifiers to be used in a seamless manner. It would be even more
powerful with Tango-like format specifiers, i.e. "{...}", but I guess
that ship sailed a long time ago. ("%{...}s" could be an alternative,
though.)
-Lars
More information about the Digitalmars-d
mailing list