TempAlloc Overhaul

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jun 17 10:40:27 PDT 2011


On 6/17/11 11:50 AM, Jose Armando Garcia wrote:
> On Fri, Jun 17, 2011 at 11:12 AM, dsimcha<dsimcha at yahoo.com>  wrote:
>> On 6/16/2011 11:46 PM, Andrei Alexandrescu wrote:
>>> * newArray ->  "For performance reasons, the returned array is not
>>> initialized." Then call it newUninitializedArray. Make safety the
>>> default and lack thereof the verbose alternative.
>>
>> Here I'm going to have to strongly disagree with you.  The whole point of
>> TempAlloc is that it's a performance hack.  In general I agree it's better
>> to do the safe thing by default, but libraries specifically written as
>> performance hacks are an exception.  In TempAlloc it makes sense to do the
>> efficient thing by default.  I personally would never use newArray as
>> opposed to newUninitializedArray and TempAlloc.newUninitializedArray (31
>> characters) feels **ridiculously** verbose and would clutter the API.
>
> Hmm. If this is a hack then what is it doing in the std library for
> the language?!

For speed purposes. We're trying to minimize patently unsafe constructs 
in the language proper, but I see nothing wrong with having library 
artifacts that sacrifice safety for speed when the gain is significant.

Andrei


More information about the Digitalmars-d mailing list