andalso, orelse
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?
I guess andalso is if left then right else false
and orelse is if left then true else right
Yes, I understand the need for short circuit logical operators, but I haven’t decided how to provide them; they can be implemented as:
- special built-in operators (like Erlang’s
andalsoandorelse), or - 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.