DIP9 -- Redo toString API

Steven Schveighoffer schveiguy at yahoo.com
Fri Nov 19 04:46:10 PST 2010


On Thu, 18 Nov 2010 17:43:51 -0500, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Steven Schveighoffer:
>
>> I just created a new D Improvement Proposal to fix the toString problem  
>> I
>> brought up several posts ago.
>
> Thank you for writing the DIP. It looks interesting. I suggest to add an  
> example, the implementation of toString() and writeTo() for a simple  
> struct like this (or a class), so it's easy to compare them (code  
> untested):
>
> struct Pair(T1, T2) {
>     T1 first;
>     T2 second;
>     string toString() {
>         return format("Pair(%s, %s)", first, second);
>     }
>     void writeTo(scope void delegate(in char[] data) sink, string  
> format="") const {
>         // code here...
>     }
> }

Will do.

-Steve


More information about the Digitalmars-d mailing list