Does dmd have SSE intrinsics?
Christopher Wright
dhasenan at gmail.com
Tue Sep 22 16:06:22 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).
You could ease the restriction by disallowing implicit conversion from
static to dynamic arrays in certain situations. A function returning a
dynamic array cannot return a static array; you cannot assign the return
value of a function returning a static array to a dynamic array.
Or in those cases, put the static array on the heap.
More information about the Digitalmars-d
mailing list