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

Add builtin if #1585

Merged
merged 1 commit into from
Oct 14, 2022
Merged

Add builtin if #1585

merged 1 commit into from
Oct 14, 2022

Conversation

paulcadman
Copy link
Collaborator

@paulcadman paulcadman commented Oct 13, 2022

A builtin if allows a backend to translate if directly, so that only one branch is evaluated.

builtin boolean-if
if : {A : Type} → Bool → A → A → A;
if true x _ := x;
if false _ x := x;

An example compilation of if is given for the legacy backend for testing.

I think there was some debate on whether to include if as a builtin, or wait until we have a laziness mechanism. Perhaps we could keep this builtin as a temporary construct - we'll need this to make use of if in Juvix core.

This closes #1348

@paulcadman paulcadman added enhancement New feature or request c-backend labels Oct 13, 2022
@paulcadman paulcadman added this to the 0.2.6 milestone Oct 13, 2022
@paulcadman paulcadman self-assigned this Oct 13, 2022
```
builtin boolean-if
if : {A : Type} → Bool → A → A → A;
if true x _ := x;
if false _ x := x;
```

This allows a backend to translate if directly, so that only one branch
is evalutated.

An example compilation of if is given for the legacy backend for testing.
@paulcadman paulcadman merged commit be9872e into main Oct 14, 2022
@paulcadman paulcadman deleted the builtin-if branch October 14, 2022 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-backend enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make if lazy
2 participants