Changeing return type of struct.toString()

Don nospam at
Sun Feb 12 18:21:42 PST 2012

On 12.02.2012 19:36, Benjamin Thaut wrote:
> I'm currently trying to use D without a gc and didn't have major
> problems so far. A minor issues is that struct.toString() returns a
> string and this will almost allways leak memory when this is called.
> The question now is, can I change the return type of struct.toString()
> somewhere inside druntime or is it hardcoded in the compiler?
> It was possible without any problems to change the return type of
> Object.toString() and therefore every class in D because Object is the
> baseclass for every class. Is there something similar for structs?
> Kind Regards
> Benjamin Thaut

I don't know why struct toString() still exists. It's a legacy from the 
very beginning of D, back when the language didn't even have templates.
std.format doesn't even require it, any more.

More information about the Digitalmars-d mailing list