On Fri, 19 Nov 2010 02:27:07 -0500, Lars T. Kyllingstad
<[email protected]> wrote:
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.
Yes, I was not clear on what is passed in via format specifier. It should
be more clear, will fix.
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.)
I think it leaves room for improvement, all that is necessary is to change
the grammar for format specifiers to allow some kind of bracketing, and
then we can have as much custom specifier as necessary. I didn't want to
pretend I was good at tweaking format grammar specs, so I left it out :)
All I said was that the format specifiers should follow the rules for
standard format specifiers.
-Steve