Can't understand the application of delegates in toString() functions
Heisenberg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 7 09:03:43 PST 2016
On Monday, 7 November 2016 at 16:54:06 UTC, Ali Çehreli wrote:
> On 11/07/2016 08:40 AM, Heisenberg wrote:
>> [...]
>
> Exactly how it happens requires explaining a long chain of
> function calls. Probably that's why the author did not
> elaborate further. ;) I've probably omitted some steps here but
> I think the following is close enough:
>
> - writeln() that's in the sample code calls write() with the
> addition of '\n'.
>
> - write() eventually calls formattedWrite() with a
> lockingTextWriter as the writer:
>
> https://github.com/dlang/phobos/blob/master/std/stdio.d#L1401
>
> - formattedWrite() calls formatValue():
>
> https://github.com/dlang/phobos/blob/master/std/format.d#L2906
>
> - formatValue() calls formatObject() and that's the one that
> makes a distinction between different overloads of toString():
>
> https://github.com/dlang/phobos/blob/master/std/format.d#L2805
>
> - formatObject() calls put(), which finally uses the 'sink'
> parameter as an output range and fills in with characters.
>
> Ali
I see now. :) Sounds like I have to finish the whole book to be
able to grasp all of that a little better. I think I do get a
general picture now, though. Thanks for a quick reply, everyone!
More information about the Digitalmars-d-learn
mailing list