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

Multiway if syntax #2736

Closed
lukaszcz opened this issue Apr 18, 2024 · 0 comments · Fixed by #2770
Closed

Multiway if syntax #2736

lukaszcz opened this issue Apr 18, 2024 · 0 comments · Fixed by #2770
Assignees
Labels
enhancement New feature or request parsing syntax
Milestone

Comments

@lukaszcz
Copy link
Collaborator

Our if is actually not readable, especially with nested ifs. Instead of writing e.g.

    if
      (y1 == 0)
      q
      (if
        (y2 == 0)
        p
        (if
          (x1 == x2)
          (if (y1 == y2) (double p) (mkPoint 0 0))
          (let
            slope := (y1 - y2) / (x1 - x2);
            r_x := slope * slope - x1 - x2;
            r_y := slope * (x1 - r_x) - y1;
          in mkPoint r_x r_y)));

we should be able to write e.g.

    if
      | y1 == 0 := q
      | y2 == 0 := p
      | x1 == x2 := 
          if
            | y1 == y2 := double p
            | else := mkPoint 0 0
      | else :=
          let
            slope := (y1 - y2) / (x1 - x2);
            r_x := slope * slope - x1 - x2;
            r_y := slope * (x1 - r_x) - y1;
          in mkPoint r_x r_y;
@lukaszcz lukaszcz added this to the 0.6.2 milestone Apr 18, 2024
@lukaszcz lukaszcz self-assigned this May 6, 2024
lukaszcz added a commit that referenced this issue May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parsing syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants