Skip to content

Implement first draft of or-patterns#1081

Open
b-studios wants to merge 8 commits into
mainfrom
feature/or-patterns
Open

Implement first draft of or-patterns#1081
b-studios wants to merge 8 commits into
mainfrom
feature/or-patterns

Conversation

@b-studios
Copy link
Copy Markdown
Collaborator

This is a first attempt to implement or patterns (such as requested by #805).

It also supports nested or patterns, but exhaustivity is not yet implemented.

@b-studios b-studios marked this pull request as draft July 14, 2025 10:51
@b-studios
Copy link
Copy Markdown
Collaborator Author

Please note that this generates code (after inlining) such as

      if (infixEq_85("c", "a")) {
        let tmp_1303570 = println_1("hello")
        l_1303481(tmp_1303570)
      } else {
        if (infixEq_85("c", "b")) {
          let tmp_1303572 = println_1("hello")
          l_1303481(tmp_1303572)
        } else {
          let tmp_1303573 = println_1("world")
          l_1303481(tmp_1303573)
        }
      }

while the following would be better (for sharing code)

      if (infixEq_85("c", "a") || infixEq_85("c", "b")) {
        let tmp_1303570 = println_1("hello")
        l_1303481(tmp_1303570)
      } else {
        let tmp_1303573 = println_1("world")
        l_1303481(tmp_1303573)
      }

@dvdvgt dvdvgt marked this pull request as ready for review March 12, 2026 16:06
@marvinborner marvinborner moved this from Todo to Waiting for Review in Effekt Hackathon Spring 2026 Apr 10, 2026
@jiribenes
Copy link
Copy Markdown
Contributor

Bikeshed: If possible, I'd like this to use or and also support if (foo is "hello" or foo is "bar") { ... } :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting for Review

Development

Successfully merging this pull request may close these issues.

4 participants