Top 5

Christopher Wright dhasenan at gmail.com
Sat Oct 11 07:41:45 PDT 2008


Andrei Alexandrescu wrote:
> Steven Schveighoffer wrote:
>> "Andrei Alexandrescu" wrote
>>>> typeof(d) == char[15]*
>>> just char[15].
>>
>> What is the point of that?  Why wouldn't you just say:
>>
>> char[15] d;
> 
> Only uniformity. In general Type() creates an instance of Type. Easy!
> 
>>> S * pS = allocate!(S)(... optional args ...);
>>
>> Ugh.  How many extra 'wrapper' functions are built into the code 
>> because of this?  I suppose it probably would be inlined.
> 
> Performance is not to worry about. allocate does only a call to 
> gc.allocate, the requisite initialization, and a cast. The cost of call 
> to gc.allocate dwarfs the call overhead even in absence of inlining.

Compile times are something to worry about. I'm quite hesitant to use 
templates when there is a reasonable alternative; they tend to increase 
compilation times dramatically, even if they're relatively simple.

In this case, it's equivalent to:
S* obj = allocate!(typeid (S) ...);



More information about the Digitalmars-d mailing list