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

support switch-case statements #15504

Open
3esmit opened this issue Oct 10, 2024 · 0 comments
Open

support switch-case statements #15504

3esmit opened this issue Oct 10, 2024 · 0 comments
Labels

Comments

@3esmit
Copy link
Contributor

3esmit commented Oct 10, 2024

Abstract

Switch case is important for code cleanness. It's a common feature in all high level languages.

Motivation

While I undestand there is some complex edge cases to deal with on EVM for this control structure been implemented, it should start as simple as possible.

Specification

First iteration:

  • uint256
enum MyEnum { A, B, C };
// (...)
MyEnum b = MyEnum.B;
switch(uint(b)){
     default:
         emit MyEvent();
     case uint(MyEnum.A):
         //(...)
         break;
     case uint(MyEnum.B):
        //(...)
        break;
}

Second iteration:

  • enum type;

Third iteration:

  • custom errors

Fouth iteration:

  • complex structures

Whatever would cause a complexity or need more discussion to be porperly implemented should be left to a later iteration. In my example I used a default: without break;, if that would be difficult to solve, left it for a later iteration.

Backwards Compatibility

@3esmit 3esmit added the feature label Oct 10, 2024
@ethereum ethereum deleted a comment Oct 27, 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

1 participant