On 02/12/2010 21:08, Steven Schveighoffer wrote:
On Thu, 02 Dec 2010 11:31:49 -0500, Bruno Medeiros
<brunodomedeiros+s...@com.gmail> wrote:

On 21/11/2010 17:21, Don wrote:

That idea is quite idiotic indeed, no question about it. However, that
is not toString() 's idea! The point of toString (at least across
languages, not D specifically) is to provide a *default*
representation of a type.

It doesn't preclude other representations, and if format&friends
(writef, etc.), don't provide an integrated way to create/write a
string using custom formats for a given object/struct, that is
format's problem, it is not toString's fault.

to!string(x) will handle what toString does now.


So? What was the point here, I didn't get it.

In fact, I think that coding only a default toString for a type may be
more common than otherwise (coding a toString that actually uses the
format specifiers). The string based format specifier is just not that
common outside of numerical types.

You can ignore the format specifier if you want to.

-Steve

For calling toString, yes, you can ignore it. But as for defining the toString method, not entirely, you still have to write the format parameter (", string format = null"). After that it won't hinder you in any way, it will just be unnecessary visual baggage. So the downside of having to write that extra parameter is incredibly low, it is merely aesthetic (plus the initial one-off impact of people learning what the format parameter is for). However, toString is a core part of the language, and a very common to define, and if D were to gain more mainstream usage, I worry that something like 98% (or something like that) of all toStrings would not use format, so it seems like a bit of a waste.

It is not an issue I care that much about, only a little bit.

--
Bruno Medeiros - Software Engineer

Reply via email to