Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement for ITE #211

Open
katat opened this issue Oct 24, 2024 · 2 comments
Open

Enhancement for ITE #211

katat opened this issue Oct 24, 2024 · 2 comments
Labels

Comments

@katat
Copy link
Collaborator

katat commented Oct 24, 2024

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() 
};
@katat katat mentioned this issue Oct 24, 2024
2 tasks
@mimoo
Copy link
Contributor

mimoo commented Oct 25, 2024

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?

@katat katat added easy medium and removed easy labels Oct 28, 2024
@katat
Copy link
Collaborator Author

katat commented Oct 28, 2024

Sure, I added a few examples.

@katat katat changed the title allow literal in ITE Enhancement for ITE Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants