I have a plan.. I really DO

12345swordy alexanderheistermann at gmail.com
Fri Jul 6 16:54:20 UTC 2018


On Friday, 6 July 2018 at 15:19:33 UTC, Ecstatic Coder wrote:
> On Friday, 6 July 2018 at 14:52:46 UTC, 12345swordy wrote:
>> On Friday, 6 July 2018 at 14:11:05 UTC, Ecstatic Coder wrote:
>>> On Friday, 6 July 2018 at 13:50:37 UTC, 12345swordy wrote:
>>>> [...]
>>>
>>> +1
>>>
>>> Just one silly question.
>>>
>>> Can the following "naive" D code trigger a garbage collection 
>>> stall ?
>>>
>>> score.Text = point_count.to!string() ~ " POINTS";
>>>
>> The correct answer is: I don't know, as I don't know what 
>> "point_count" is in the first place, as it never been defined.
>>
>> -Alex
>
> Actually you answer was right even if the point count was not 
> stored as an integer ;)
>
> For C++, the answer is : never.
>
> Two small memory blocks will have to be allocated from the 
> memory pool, which is not smart, obviously, but apart of that, 
> nothing to worry about.
>
> Because there is no garbage collector in C++, memory has to be 
> allocated and deallocated in a continuous manner...

Also if your concatenate string in a loop in c# then you use the 
https://www.dotnetperls.com/string-join function as it simpler 
and faster.
There is no reason why we can't have the function equivalent in D.

-Alexander


More information about the Digitalmars-d-announce mailing list