grauzone wrote:
Don wrote:
grauzone wrote:
Don wrote:
Lutger wrote:
Don wrote:
...
There is a definite use for such as thing. But the existing
toString()
is much, much worse than useless. People think you can do
something with
it, but you can't.
eg, people have asked for BigInt to support toString(). That is an
over-my-dead-body.
How are you supposed to print a BigInt then?
How are you supposed to print one with it? It doesn't help.
(The problem even more obvious if you consider BigFloat).
Just put it into an "interface DebugOutput", remove
Object.toString(), and be done with it. That interface could be
defined in the same module as writefln or format, and its use will be
clear.
BigInt is a struct, so it doesn't have interfaces.
Structs are a different matter. Nothing dictates that a struct should
have a toString method, or what arguments that method should have,
right? (There's this compiler/runtime hack to make struct toString work
with writefln, but now that wirtefln uses compile time varargs, it can go.)
This discussion is about that hack. Yes, it might be unnecessary if
compile time varargs work sufficiently well.