Unity-Technologies / Unity.Mathematics

The C# math library used in Unity providing vector types and math functions with a shader like syntax
Other
1.38k stars 156 forks source link

Design reason behind select() parameter ordering #75

Closed IceSentry closed 4 years ago

IceSentry commented 5 years ago

So, math.select() essentially maps to a ternary operator. Is there a design reason why the parameters are exactly in the reverse order of a ternary operator? It was really counter intuitive to me when I first saw that.

I'm not sure I understand why it wouldn't use the same ordering as the ternary operator. Something like

select(condition, a, b) //a if true, otherwise b

It seems a lot more intuitive to follow the established order of the ternary since it's exactly what it does anyway.

sheredom commented 4 years ago

I wasn't here for its inception - but select having the opposite ordering to ternary is very common in the GPU shader people that Unity.Mathematics is intended to be familiar to: