noir icon indicating copy to clipboard operation
noir copied to clipboard

Implement && and ||

Open jfecher opened this issue 3 years ago • 5 comments

These logical operators are currently unimplemented presumably because they are sugar for if a then b else false and if a then true else b respectively - and if statements are also unimplemented. If keeping lazy evaluation for these operators would be as slow as we believe if will be at runtime - it may be preferable to make these operators strict instead.

jfecher avatar Feb 09 '22 17:02 jfecher

Update: with the approach of preventing side effectful computations in if branches via passing a boolean condition to the side effectful function, we could use that to implement these operators if we want to as well. The naive desugaring to if in my previous comment would automatically benefit from handling side effects this way. Then we can implement it as long as it wouldn't incur a large runtime penalty.

jfecher avatar Mar 01 '22 13:03 jfecher

@jfecher can this be closed?

kevaundray avatar Jan 21 '23 18:01 kevaundray

No, it is still a valid design question of whether we want these operators. It could make the Rust -> Noir transition slightly easier for example.

jfecher avatar Jan 23 '23 18:01 jfecher