dfinity / motoko

Simple high-level language for writing Internet Computer canisters
Apache License 2.0
515 stars 97 forks source link

language-manual: Binary logical operators missing #3757

Open timohanke opened 1 year ago

timohanke commented 1 year ago

https://github.com/dfinity/motoko/blob/c6d1af06ea9c5751d1cde37ff94dbab97977e1f0/doc/md/language-manual.md?plain=1#L236-L293

In this section it seems that all binary operators are listed but not the logical ones. Is that missing?

Further down in https://github.com/dfinity/motoko/blob/c6d1af06ea9c5751d1cde37ff94dbab97977e1f0/doc/md/language-manual.md?plain=1#L1682-L1684 the statement does not seem to be correct for binary logical operators. For example, <exp1> and <exp2> would not evaluate <exp2> if <exp1> evaluates to false. But the text says that <exp2> is evaluated unless the evaluation of <exp1> traps.

crusso commented 1 year ago

Sorry, that is a bit confusing but the Boolean constructs and and or and not are not included in <binop>, but instead have dedicated grammar productions and sections (eg https://internetcomputer.org/docs/current/motoko/main/language-manual#and) explaining their use, precisely becauseandandorare short-circuiting/lazy, unlike` which always evaluates both arguments.

But I should probably delete class L which is defined but never used in the tables.

timohanke commented 1 year ago

Thanks. I had not seen the dedicated sections on the and/or operators but see them now. Please close the issue when class L is removed.