4 ms·
I'm not familiar with Sail, but the reason for separate logical operators is that you want short-circuiting behavior. For example, in: (a != NULL) && a->x
by pdw 3y ago
I'm not familiar with Sail, but the reason for separate logical operators is that you want short-circuiting behavior. For example, in:
(a != NULL) && a->x
You don't want to right-hand side to be evaluated if the left-hand side is false.
- Denvercoder9 3y agoI'm also not familiar with Sail, but you could have a single token ("&&") behave as either a bitwise or logical AND, depending on the context: if both operands are an boolean, operate logically, if both operands are an integer, operate bitwise. The complexity lies in what you do with mixed expressions. One solution is to just forbid them. This makes bitwise expressions nested within logical expressions more verbose (you'd need to add a cast), but I'd wager that those aren't used often in most high-level languages.
- IshKebab 3y agoIt does short circuit if the parameters are booleans.