More on vectorized comparisons

bearophile bearophileHUGS at lycos.com
Thu Aug 23 15:13:01 PDT 2012


Sean Cavanaugh:

> Well, right now the binary operators == != >= <= > and < are 
> required to return bool instead of allowing a user defined 
> type, which prevents a lot of the sugar you would want to make 
> the code nice to write.

The hypothetical D sugar I was looking for is this, where 'a', 
'b' and 'c' are normal dynamic arrays of doubles (not of float[4] 
of double[2]) (currently this code is a syntax error):

if (a[] > 0)
     b[] += c[];


The front-end is able to implement those two lines of code as it 
likes, like seeing those normal arrays as arrays of double[2] (or 
double[4] on more modern CPUs) and put there all the needed 
intrinsics or assembly needed to implement that semantics.

So what's the problem the > operator causes in this code?

Bye,
bearophile


More information about the Digitalmars-d mailing list