On Thursday, 27 February 2020 at 18:58:40 UTC, Walter Bright wrote:
On 2/27/2020 1:45 AM, Rainer Schuetze wrote:
The string buffer could also be stack allocated or manually managed with
malloc/free by the string interpolation type.

It's quite a big deal to make that work, and does not address the inherent inefficiency of it.

printf, for all its faults, is very efficient, and one reason is it does not require arbitrary temporary storage. Another is it does not require exception handlers. I, for one, simply would not use such when printf is available.

It isn't that efficient. There are a lot of implementations faster than it, and funnily enough they allocate memory, use exceptions, and RAII.

People often overlook how *expensive* RAII is. Turn exception handling on and have a look at the generated code.

There was a whole other thread about this, and people found the assembly generated isn't all that different. Yes throwing exceptions is expensive, but what you are talking about, the cost of not throwing them, it really isn't. You are making it out to be a bigger problem than it actually is. If it caused such a huge performance hit, then exceptions simply wouldn't be used at all in C++. But that's not the case.

It's a minor syntactic convenience with an unexpected large and hidden cost. That's not what D is about.

Leave this at the user's discretion with:

    f(format("hello %betty"));

where the user chooses via the format function which method of handling temporaries he finds appropriate.

There are quite a few places that D has large hidden costs. Hell GC and any feature or otherwise that uses it is a large and hidden cost. You can't really say D is not about unexpected large and hidden costs when it has a GC integrated into quite a few features that make it invisible.



Reply via email to