Does dmd have SSE intrinsics?
Daniel Keep
daniel.keep.lists at gmail.com
Tue Sep 22 06:49:43 PDT 2009
Robert Jacques wrote:
> On Tue, 22 Sep 2009 07:09:09 -0400, bearophile
> <bearophileHUGS at lycos.com> wrote:
>> Robert Jacques:
> [snip]
>>> Also, another issue for game/graphic/robotic programmers is the
>>> ability to
>>> return fixed length arrays from functions. Though struct wrappers
>>> mitigates this.
>>
>> Why doesn't D allow to return fixed-sized arrays from functions? It's
>> a basic feature that I can find useful in many situations, it looks
>> more useful than most of the last features implemented in D2.
>>
>> Bye,
>> bearophile
>
> Well, fixed length arrays are an implicit/explicit pointer to some
> (stack/heap) allocated memory. So returning a fixed length array usually
> means returning a pointer to now invalid stack memory. Allowing
> fixed-length arrays to be returned by value would be nice, but basically
> means the compiler is wrapping the array in a struct, which is easy
> enough to do yourself. Using wrappers also avoids the breaking the
> logical semantics of arrays (i.e. pass by reference).
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.
P.S. And another thing while I'm at it: why can't we declare void
variables? This is another thing that really complicates generic code.
More information about the Digitalmars-d
mailing list