noname
noname copied to clipboard
Enhancement for ITE
The current ITE requires the branches to be variables:
bits[index] = if bit_num == 1 {true_val} else {false_val};
This restriction makes it inconvenient to use the ITE in noname. Ideally, we should allow expressions in the branches.
Examples for feature enhancement:
Allow literals
bits[index] = if bit_num == 1 {true} else {false};
num = if cond == true {1} else {0};
Allow expressions
let mut counter = 0;
// func_a and func_b has to return the same type
num = if cond == true {
counter = counter + 1;
func_a(counter);
} else {
func_b()
};
Can you label this as easy/medium/hard? Can we provide more info and ask the open source community to take a look at it?
Sure, I added a few examples.
to add to this, I don't think we should support expressions for now! but we should make sure that any types are supported though if that's not already the case