Passing dynamic arrays
Daniel Gibson
metalcaedes at gmail.com
Mon Nov 8 10:51:27 PST 2010
Daniel Gibson schrieb:
> Daniel Gibson schrieb:
>> Walter Bright schrieb:
>>> Daniel Gibson wrote:
>>>> BTW: What were the reasons to pass static arrays by value in D2
>>>> (while in D1 they're passed by reference)?
>>>
>>> It makes things like vectors (i.e. float[3]) natural to manipulate.
>>> It also segues nicely into hopeful future support for the CPU's
>>> vector instructions.
>>
>> Why can't that be done when the static arrays are passed by reference?
>
> Ah I guess you mean something like "alias float[3] vec3", so one may
> expect vec3 to behave like a value type (like when you define it in a
> struct) so it's passed by value.
> That does make sense, even though I'm not sure what's more important:
> consistency between different kinds of arrays or expectations towards
> typed defined from static arrays. ;-)
>
> I still don't get the part with the CPU's vector instructions though. I
> don't have any assembly knowledge an no experience with directly using
> CPU's vector instructions, but the example of a C function wrapping SSE
> instructions from the wikipedia article[1], which multiplies two arrays
> of floats, loads the arrays by reference and even stores the result in
> one of them.
Hrm forgot the link:
[1] http://en.wikipedia.org/wiki/Vector_processor
More information about the Digitalmars-d
mailing list