Tomek Sowiński wrote:
Don <nos...@nospam.com> napisał(a):

The efficiency issues are important, but are not the primary motivation.
toString() is just wrong. The idea that there is ONE AND ONLY ONE textual representation of an object, is, frankly, idiotic.

I always thought of toString() as an aid in debugging, where having one and only way to print out an object makes sense.

It isn't just used in debugging. It's used for writefln.
But even for debugging, it doesn't work.

If I have a struct:

struct Foo
{
   Complex!(double) val;
}

and, for debugging purposes, I want to write 'val' to 10 decimal places.
How do I do that?


But strong words suggest you see something I don't. What problems does offering choice solve? How and to whom would I pass my choice?

Creating a wrapper for the simple case is trivial, once you have the more general case.

The simple case doesn't need to integrated into the compiler and runtime at all. (Nor does the general case, actually, a fact which is not recognized in the DIP). I think it's actually a hack from the days before the language had templates.

Reply via email to