Does dmd have SSE intrinsics?

Robert Jacques sandford at jhu.edu
Tue Sep 22 10:06:05 PDT 2009


On Tue, 22 Sep 2009 12:32:25 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:
> Daniel Keep wrote:
[snip]
>>  The problem is that currently you have a class of types which can be
>> passed as arguments but cannot be returned.
>>  For example, Tango's Variant has this horrible hack where the ACTUAL
>> definition of Variant.get is:
>>      returnT!(S) get(S)();
>>  where you have:
>>      template returnT(T)
>>     {
>>         static if( isStaticArrayType!(T) )
>>             alias typeof(T.dup) returnT;
>>         else
>>             alias T returnT;
>>     }
>>  I can't recall the number of times this stupid hole in the language has
>> bitten me.  As for safety concerns, it's really no different to allowing
>> people to return delegates.  Not a very good reason, but I *REALLY* hate
>> having to special-case static arrays.
>
> Yah, same in std.variant. I think there it's called  
> DecayStaticToDynamicArray!T. Has someone added the correct handling of  
> static arrays to bugzilla? Walter wants to implement it, but we want to  
> make sure it's not forgotten.

Well, what is the correct handling? Struct style RVO or delegate  
auto-magical heap allocation? Something else?

Both solutions are far from perfect.
RVO breaks the reference semantics of arrays, though it works for many  
common cases and is high performance. This would be my choice, as I would  
like to efficiently return short vectors from functions.
Delegate style heap allocation runs into the whole  
I'd-rather-be-safe-than-sorry issue of excessive heap allocations. I'd  
imagine this would be better for generic code, since it would always work.







More information about the Digitalmars-d mailing list