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

andalso, orelse #43

Open
michallepicki opened this issue Sep 16, 2021 · 2 comments
Open

andalso, orelse #43

michallepicki opened this issue Sep 16, 2021 · 2 comments

Comments

@michallepicki
Copy link
Contributor

I find myself needing to write more complicated boolean expressions. Ideally they would also be "lazy" so wouldn't compute the right expression if left expression already gives the result.

I searched for them and only found this commit.

Are such operators (or "functions" with special semantics) planned?

@michallepicki
Copy link
Contributor Author

michallepicki commented Sep 16, 2021

I guess andalso is if left then right else false
and orelse is if left then true else right

@gfngfn
Copy link
Owner

gfngfn commented Sep 17, 2021

Yes, I understand the need for short circuit logical operators, but I haven’t decided how to provide them; they can be implemented as:

  1. special built-in operators (like Erlang’s andalso and orelse), or
  2. macros (after introducing some type-safe mechanism for writing macros).

The first one is easy to realize but somewhat ad-hoc, while the second one seems theoretically elegant and general but a bit tough to achieve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants