new should lower to a template function call

Per Nordlöw per.nordlow at gmail.com
Thu Jul 23 12:16:55 UTC 2020


On Thursday, 23 July 2020 at 10:19:41 UTC, Petar Kirov 
[ZombineDev] wrote:
>> It's a good idea, but I'd consider it a low priority since it 
>> is so easy to add scope.
>>
>> As for guaranteeing stack placement in the language spec, it's 
>> usually regarded as being in the QoI (Quality of 
>> Implementation) domain.
>
> I agree that it's not a high priority. Migrating more druntime 
> hook to templates is more impactful as it unlocks various 
> opportunities, whereas an optimization like this has a 
> relatively fixed improvement potential.

I actually see 3 (instead of 2) kinds of allocations here:

1. GC: destruction during `GC.collect()`
2. C/C++-style heap: (too large to fit on stack) scoped 
destruction (could be inferred?)
3. Stack: scoped destruction (inferred by LDC)

The 2. is not being discussed here. Is this case obvious or 
irrelevant? If not which part of the runtime should handle such 
allocations? The GC?


More information about the Digitalmars-d mailing list