new should lower to a template function call

Sebastiaan Koppe mail at skoppe.eu
Fri Jul 24 07:11:33 UTC 2020


On Friday, 24 July 2020 at 03:23:07 UTC, Andrei Alexandrescu 
wrote:
> On 7/23/20 2:51 PM, Stefan Koch wrote:
>> In the _worst_ case this can almost double the number of 
>> template instances.
>> I.E. when the new is inside a template itself.
>
> Not a problem. We must go with templates all the way, it's been 
> that way since the STL was created and there's no going back. 
> All transformations of nonsense C-style crap into templates in 
> object.d have been as many success stories. If anything there's 
> too few templates in there.
>
> When "new C" is issued everything is right there for the grabs 
> - everything! The instance size, the alignment, the constructor 
> to call. Yet what do we do? We gladly throw all that on the 
> floor to call a crummy C function that uses indirect access to 
> get access to those. No wonder -trace=gc is so slow. This 
> entire inefficient pomp and circumstance around creating an 
> object is an embarrassment.

Yes, I have wished many times that the call to druntime for 
newing an object was templated. For one that makes it easier to 
do without TypeInfo, but in general it gives more control.


More information about the Digitalmars-d mailing list