19068, "bradcray", "Why doesn't Chapel permit conditional expressions to be promoted?", "2022-01-20T20:19:57Z"
Since its origins, Chapel has outlawed promotion within the tests of conditionals, but it's often seemed to me that this feels like the wrong choice for conditional expressions in particular. Specifically, several times during advent of code, I found myself wanting to write things like:
var B = if A > 0 then 1 else -1;
only to get the error:
error: iterator or promoted expression iterator used in if or while condition
It's not obvious to me why we wouldn't support such promoted expressions, which seem clear and strictly more convenient than the alternatives (e.g., var B = [a in A] if a > 0 then 1 else -1;
or var B = 2*(A>0) - 1;
)