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

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

@sunjay

Description

@sunjay

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions