new should lower to a template function call

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jul 24 14:06:28 UTC 2020


On 7/24/20 4:58 AM, Stefan Koch wrote:
> On Friday, 24 July 2020 at 03:23:07 UTC, Andrei Alexandrescu wrote:
>> 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.
> 
> You say that, but we have seen problems, for example with the 
> mangle-length of huge stringswitch instances.

I looked at that. It's a non-issue. Yes, there's a long mangled name for 
a switch statement with strings. It scales up with the number of switch 
statements (with strings) and the number of strings. It's called once. 
And that's about it. It's easy to improve (e.g. by hashing) but there's 
no need to.

> Shortly after the introduction array comparison was bugged because, it 
> could not compare char[] and const char[]. They were different types and 
> would compare to false, therefore.

So there was a bug in the implementation.

I recall there was (and there may still be) a problem with things like 
array comparison because the compiler did it in different ad-hoc ways 
depending on compile- vs. run-time execution. This would be something 
very worth looking into.

> Where are the many success stories?

Lucia demonstrated dramatic improvements on array comparison speed: 
https://www.youtube.com/watch?v=P6ZST80BCIg.

> I haven't read any article about how the templates in druntime have 
> helped anyone in great capacity, (to be honest I have not looked either).

Problem is there are not enough.

We need to template all we can of druntime. All those silly C-style 
functions decaying to void* and dependencies and runtime type 
information must go.


More information about the Digitalmars-d mailing list