DIP9 -- Redo toString API

Fawzi Mohamed fawzi at gmx.ch
Fri Nov 19 03:00:11 PST 2010


On 19-nov-10, at 11:13, Lars T. Kyllingstad wrote:

> On Fri, 19 Nov 2010 10:22:29 +0100, Jacob Carlborg wrote:
>
>> On 2010-11-18 23:21, 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
>>>
>>> -Steve
>>
>> Why do we have to remove toString, can't toString call writeTo and
>> behave as it does now?
>
> Nobody's forcing anyone to remove toString(), the point is that Phobos
> just won't be using it anymore.  Furthermore, std.conv.to!string()  
> should
> be defined to call writeTo(), so you won't have to define both  
> toString()
> and writeTo() for your types.
>
> -Lars

I think that it is a good, a breaking change, but good.

having something like what I did with writeOut would minimize the  
hassles, because then you have a uniform way to print out a type:
	writeOut(sink,type,possiblyExtraArgs)
that works for everything, basic types, old style objects with  
toString,... it is useful for generic code.


More information about the Digitalmars-d mailing list