Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Boolean && and || operators do not short-circuit #72

Open
sunjay opened this issue May 20, 2017 · 0 comments
Open

Boolean && and || operators do not short-circuit #72

sunjay opened this issue May 20, 2017 · 0 comments

Comments

@sunjay
Copy link
Owner

sunjay commented May 20, 2017

Short-circuit evaluation

This is less of a problem now because we don't have functions yet (#16), but this is a very important property of booleans that should be properly implemented sooner rather than later.

The problem is that boolean operators are implemented as regular functions (like stdout.print, etc.). They just have "internal-only" names which are only callable from inside the compiler. This solution works quite well, except it doesn't work here because we want to actually delay the evaluation of the expression of the operators until we deem it necessary to evaluate them.

Two ideas:

  1. Some kind of lazy operators table in the scope which takes expressions instead of the direct scope items
  2. Special BooleanOr and BooleanAnd ast::Expression enum variants which have to be handled everywhere using a special intrinsics::boolean_or or intrinsics::boolean_and function

Either way, the solution to this needs to be thought about more before it is implemented.

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

No branches or pull requests

1 participant