primitive vector types

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Feb 21 09:32:03 PST 2009


Don wrote:
> Andrei Alexandrescu wrote:
>> Don wrote:
>>> float[4] would be a greatly superior option if it could be done.
>>> The key requirements are:
>>> (1) need to specify that static arrays are passed by value.
>>> (2) need to keep stack aligned to 16.
>>> The good news is that both of these appear to be done on DMD2-Mac!
>>
>> I agree with float[4] as a good choice. So are value semantics for 
>> T[n] implemented on the Mac??
>>
>> Andrei
> Oh. I guess it was just a proposal then, and not implemented. We're not 
> as close as I thought. Bummer.

Yah. Walter agrees that that's the right thing to do. The only thing 
that worries us is passing by-value large statically-sized vectors to 
template functions. But then gaming code wants to do exactly that. It's 
hard to figure where to draw the line. Imagine the error message "Hey, 
you're going a bit overboard by passing 512 bytes around on the stack".

Besides, we already do have a solution for pass-by-value vectors: 
Tuple!(T[N]). That would put the burden in the right place (on the 
programmer actively wanting pass-by-value). But then it's a shame that 
the built-in type T[N] is a weird exception that must be handled in all 
template code.

No idea what the right choice is. I'm just dumping whatever is buzzing 
around my head whenever I think of the issue.


Andrei



More information about the Digitalmars-d mailing list