primitive vector types (permutation syntax)

Denis Koroskin 2korden at gmail.com
Sun Feb 22 06:05:32 PST 2009


On Sun, 22 Feb 2009 16:51:10 +0300, Christopher Wright <dhasenan at gmail.com> wrote:

> Denis Koroskin wrote:
>> 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];
>>  How would you implement it for user-defined types?
>
> T[] opIndex(int[] indices) { ... }
> void opIndexAssign(int[] indices, T[] values) { ... }

How about ranges included - v[0..3, 6, 5, 7..len] ?




More information about the Digitalmars-d mailing list