Skip to content

Swap bitwise with logical operators #4

@SheepTester

Description

@SheepTester

Proposal

The shorter variants should be used for logical operators rather than bitwise operators as the former is used more often, so

  • & | ~ are the logical AND, OR, and NOT operators, respectively.
  • && || ! are the bitwise AND, OR, and NOT operators, respectively.

^ should also be reserved for exponentiation, so XOR can be something obscure like ^^.

Rationale

&, |, and ~ have roots that might be more recognizable. For example, & is used in English for "and," and ~ is used for negation in math. | is already used in some syntaxes for multiple options, like regex a|b. ^ is commonly used for exponentiation.

In addition, a single character is easier to type (though admittedly the impact of this is negligible), so it should be used for the operator that is used more often.

Duplicating the symbol for bitwise operators would be in line with the bitwise shift operators, >> and <<. Good thing existing languages don't do it the other way around!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions