On 25 October 2012 13:38, Iain Buclaw <span dir="ltr"><<a href="mailto:ibuclaw@ubuntu.com" target="_blank">ibuclaw@ubuntu.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 25 October 2012 09:36, Manu <<a href="mailto:turkeyman@gmail.com">turkeyman@gmail.com</a>> wrote:<br>
> On 25 October 2012 02:18, Iain Buclaw <<a href="mailto:ibuclaw@ubuntu.com">ibuclaw@ubuntu.com</a>> wrote:<br>
>><br>
>> On 25 October 2012 00:16, Manu <<a href="mailto:turkeyman@gmail.com">turkeyman@gmail.com</a>> wrote:<br>
>> > On 25 October 2012 02:01, Iain Buclaw <<a href="mailto:ibuclaw@ubuntu.com">ibuclaw@ubuntu.com</a>> wrote:<br>
>> >><br>
>> >> On 24 October 2012 23:46, Manu <<a href="mailto:turkeyman@gmail.com">turkeyman@gmail.com</a>> wrote:<br>
>> >><br>
>> >> > Let's consider your example above for instance, I would rewrite<br>
>> >> > (given<br>
>> >> > existing syntax):<br>
>> >> ><br>
>> >> > // vector length of context = 1; current_mask = T<br>
>> >> > int4 v = [0,3,4,1];<br>
>> >> > int4 w = 3; // [3,3,3,3] via broadcast<br>
>> >> > uint4 m = maskLess(v, w); // [T,F,F,T] (T == ones, F == zeroes)<br>
>> >> > v += int4(1); // [1,4,5,2]<br>
>> >> ><br>
>> >> > // the if block is trivially rewritten:<br>
>> >> > int4 trueSide = v + int4(2);<br>
>> >> > int4 falseSize = v + int4(3);<br>
>> >> > v = select(m, trueSide, falseSide); // [3,7,8,4]<br>
>> >> ><br>
>> >> ><br>
>> >><br>
>> >> This should work....<br>
>> >><br>
>> >> int4 trueSide = v + 2;<br>
>> >> int4 falseSide = v + 3;<br>
>> ><br>
>> ><br>
>> > Probably, just wasn't sure.<br>
>><br>
>> The idea with vectors is that they support the same operations that D<br>
>> array operations support. :-)<br>
><br>
><br>
> I tried to have indexing banned... I presume indexing works? :(<br>
<br>
</div></div>You can't index directly, no.  Only through .array[] property, which<br>
isn't an lvalue.<br></blockquote><div><br></div><div>Yeah, good. That's how I thought it was :)</div><div><br></div><div>Let me rewrite ti again then:</div><div><br></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
int4 v = [0,3,4,1];</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">int4 w = 3; // [3,3,3,3] via broadcast<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
v = selectLess(v, w, v + 3, v + 4); // combine the prior few lines: v < w = [T,F,F,T]  ->  [0+3, 3+4, 4+4, 1+3] == [3,7,8,4]</div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">I think this is far more convenient than any crazy 'if' syntax :) .. It's also perfectly optimal on all architectures I know aswell!</div>
</div>