Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

26
  • 2
    Thank you. This is the real eye opener for me. Too bad I cannot accept two answers. Commented Sep 30, 2019 at 18:49
  • 11
    I don't think this is a good way to think of & and &&. While eagerness is one of the differences between & and &&, & behaves completely differently from an eager version of &&, particularly in languages where && supports types other than a dedicated boolean type. Commented Oct 1, 2019 at 1:51
  • 14
    For example, in C and C++, 1 & 2 has a completely different result from 1 && 2. Commented Oct 1, 2019 at 2:37
  • 7
    @ZizyArcher: As I noted in the comment above, the decision to omit a bool type in C has knock-on effects. We need both ! and ~ because one means "treat an int as a single Boolean" and one means "treat an int as a packed array of Booleans". If you have separate bool and int types then you can have just one operator, which in my opinion would have been the better design, but we're almost 50 years late on that one. C# preserves this design for familiarity. Commented Oct 1, 2019 at 13:12
  • 3
    @Steve: If the answer seems absurd then I have made a poorly expressed argument somewhere, and we ought not to rely on an argument from authority. Can you say more about what seems absurd about it? Commented Oct 1, 2019 at 13:13