06-Jan-2013 23:55, Philippe Sigaud пишет:
On Sun, Jan 6, 2013 at 6:49 PM, Dmitry Olshansky <[email protected]
<mailto:[email protected]>> wrote:

    Regarding toString there is a better signature that avoids useless
    allocations:

    void toString(scope void delegate(const (char)[]) sink);

    It takes a delegate to output string representation directly to the
    destination via 'sink' delegate (that may e.g. write chars to file).
    Plus the 'scope' part of declaration avoids allocating the said
    delegate on the heap.

    I'd even say that string toString(); is an artifact of the past,
    instead to!string should be used (if allocating a string is fine).


I know you explained that already, but see, that again slipped my mind.
This toString(sink) thingy seems cool, but is there a documentation on
it somewhere? Without a related doc, I fear no one will know this exists.


Guess I need to find the original on toString and bit-blit it over with this new sink thingy ;)

--
Dmitry Olshansky

Reply via email to