In #35 we added control flow. One ideas was to let ternary operations (.. if .. else ..) be translated to co_select: Choose between two objects depending on the truth value of another object. This enables if-like behavior without introducing branching. Anyway, that idea failed because it turned out too complex/iffy to reliably detect the use of ternary operations from the Python bytecode.
I think for the time being we leave it as is. I recall that some years ago ppl went to great lengths trying to avoid branching in shaders. I'm not sure how relevant that is with the current hardware.
If it turns out to still be relevant, we could:
Have another go at using ternary ops?
Introduce a simple function select(condition, ob_if_true, ob_if_false)
In #35 we added control flow. One ideas was to let ternary operations (
.. if .. else ..
) be translated toco_select
: Choose between two objects depending on the truth value of another object. This enables if-like behavior without introducing branching. Anyway, that idea failed because it turned out too complex/iffy to reliably detect the use of ternary operations from the Python bytecode.I think for the time being we leave it as is. I recall that some years ago ppl went to great lengths trying to avoid branching in shaders. I'm not sure how relevant that is with the current hardware.
If it turns out to still be relevant, we could:
select(condition, ob_if_true, ob_if_false)