toString refactor in druntime

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 8 02:25:15 PST 2014


On Monday, 3 November 2014 at 16:02:23 UTC, Steven Schveighoffer 
wrote:
> On 10/31/14 3:07 PM, H. S. Teoh via Digitalmars-d wrote:
>> On Fri, Oct 31, 2014 at 12:04:24PM -0700, Walter Bright via 
>> Digitalmars-d wrote:
>>> On 10/27/2014 12:42 AM, Benjamin Thaut wrote:
>>>> I'm planning on doing a pull request for druntime which 
>>>> rewrites
>>>> every toString function within druntime to use the new sink
>>>> signature. That way druntime would cause a lot less 
>>>> allocations which
>>>> end up beeing garbage right away. Are there any objections 
>>>> against
>>>> doing so? Any reasons why such a pull request would not get 
>>>> accepted?
>>>
>>> Why a sink version instead of an Output Range?
>>
>> To allow toString to be a virtual function, perhaps?
>>
>> Besides, the sink version basically allows encapsulation of an 
>> output
>> range -- instead of calling x.toString(outputRange) you just 
>> write:
>>
>> 	x.toString((const(char)[] data) { outputRange.put(data); });
>
> No, please don't do that. It's put(outputRange, data);
>
> -Steve

Why?


More information about the Digitalmars-d mailing list