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

elseif #27

Closed
odino opened this Issue Dec 19, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@odino
Copy link
Collaborator

odino commented Dec 19, 2018

No description provided.

@odino odino added the enhancement label Dec 19, 2018

@odino odino modified the milestones: 0.9, preview-1, preview-2, preview-3 Dec 19, 2018

@odino odino modified the milestones: preview-3, 1.0 Dec 27, 2018

odino added a commit that referenced this issue Jan 26, 2019

Implemented `else if`, closes #27
This commit adds the ability to add multiple IF
conditions in an IF block by using `if else`:

```
if x {
  ...
} else if y {
  ...
} else if z {
  ...
} else {
  ...
}
```

I decided to change the data structure that represents
IFs because it was very limited, only allowing for
a condition, a consequence and an alternative consequence.

Now IFs are a list of `Scenario`, made of conditions and
consequences. If we encounter a bare `else` we set the condition
of that scenario to true, so that it always evaluates to true.

One funny thing that this structure does is that it allows
for code like this:

```
if x {
  ...
} else {
  ...
} else if y {
  ...
}
```

(`else` before `else if`)

I honestly don't mind having this (it's a fun easter egg), but
we might want to raise a parser error later on if users find it
annoying.

odino added a commit that referenced this issue Jan 26, 2019

Implemented `else if`, closes #27
This commit adds the ability to add multiple IF
conditions in an IF block by using `if else`:

```
if x {
  ...
} else if y {
  ...
} else if z {
  ...
} else {
  ...
}
```

I decided to change the data structure that represents
IFs because it was very limited, only allowing for
a condition, a consequence and an alternative consequence.

Now IFs are a list of `Scenario`, made of conditions and
consequences. If we encounter a bare `else` we set the condition
of that scenario to true, so that it always evaluates to true.

One funny thing that this structure does is that it allows
for code like this:

```
if x {
  ...
} else {
  ...
} else if y {
  ...
}
```

(`else` before `else if`)

I honestly don't mind having this (it's a fun easter egg), but
we might want to raise a parser error later on if users find it
annoying.

@odino odino closed this Jan 26, 2019

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