primitive vector types (permutation syntax)

Denis Koroskin 2korden at gmail.com
Sun Feb 22 03:33:43 PST 2009


On Sun, 22 Feb 2009 14:02:53 +0300, Mattias Holm <hannibal.holm at gmail.com> wrote:

> I think that the following would work reasonably well:
>
> 	allow the [] operator for arrays to take comma separated lists of  
> indices.
>
> So the OpenCL like statement:
>
> 	v.xyzw = v2.wzyx;
>
> will be written as:
>
> 	v[0,1,2,3] = v2[3,2,1,0];
>
> Would this be ok? This is a general extension of the array slicing, and  
> it might be possible to permute with a combination of slices and indices  
> like this (i.e. v[0..3, 6, 5, 7.. len]). Is permutation operations  
> something that Walter would be willing to add?
>
> As said by someone else in this thread, there need to be a way to  
> specify that static arrays are passed by value, so can the ref keyword  
> be paired with the oposite "byval" or something similar.
>
> And also, functions need to be able to return static arrays which is not  
> possible at the moment.
>
> Note that the support should be general and work with any array type (so  
> that you can get YMM support whenever that makes it into the future  
> chips).
>
>
> / Mattias
>

How would you implement it for user-defined types?





More information about the Digitalmars-d mailing list