My Long Term Vision for the D programming language

max haughton maxhaton at gmail.com
Thu Nov 25 23:26:06 UTC 2021


On Thursday, 25 November 2021 at 20:41:07 UTC, Elronnd wrote:
> On Thursday, 25 November 2021 at 15:42:28 UTC, max haughton 
> wrote:
>> Moving an unbounded allocation to malloc and free is fine. 
>> LIFO is totally irrelevant.
>>
>> The point is avoiding putting pressure on the GC. If you want 
>> to be clever you can probably come up with some hybrid 
>> arrangement that tries to use the stack if it can or has a 
>> buffer somewhere.
>
> LIFO is a useful property that you can take advantage of.  Why 
> would you _want_ to allocate on the heap when you could 
> allocate on [some kind of] stack?
>
> Re GC pressure, you get the same amount of pressure (amortized, 
> assuming bounded allocation size and call-stack depth) if you 
> allocate with the gc and then GC.free at the end of the scope.

Because it's overly complicated. You can have a parallel stack if 
you want but KISS.

The GC could collect at the first allocation. The point is to 
avoid the GC entirely, more of a latency thing than throughput. 
Assuming the analysis is reliable in the frontend this also 
allows the function to be @nogc without forcing the programmer to 
do the memory allocation themselves.


More information about the Digitalmars-d mailing list