DIP9 -- Redo toString API

bearophile bearophileHUGS at lycos.com
Thu Nov 18 14:43:51 PST 2010


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...
    }
}

Bye,
bearophile


More information about the Digitalmars-d mailing list