Skip to content

Short-circuiting logical expressions #19

@certik

Description

@certik

Currently one cannot write things like:

if (i < size(a) .and. a(i) == 0) ...

Because the compiler is free to evaluate a(i) first even if i is out of bounds. This proposal is to introduce .andthen. and .orelse. operators which will allow the above code to be written as:

if (i < size(a) .andthen. a(i) == 0) ...

An alternative proposal to this is conditional expressions (#12) which got rejected.

There is also an option to make .andthen. just .and., the argument pro is that it does not introduce any new syntax, but an argument against it is that it would change the current freedom for compilers to re-arrange logical expressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Clause 10Standard Clause 10: Expressions and assignment

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions