Skip to content

Negation X2 #157

@yaronf

Description

@yaronf

It's surprising that the language supports bitwise binary operators but not the C "complement" (~) operator. It is very useful when dealing with bit strings that represent flags, value & ~mask == desired. Granted that a workaround exists, XOR with -1.

A more complicated case is simple integer negation, -X. I just found out that the Go implementation does not support negative literal integers (-100) (the Rust code does, I believe). I tried to add them by tweaking the lexer but this results in a parser ambiguity, e.g. when parsing 200-100. One simple solution is for the lexer to only support positive literals and the parser to deal with the minus/negation distinction, but that would necessitate integer negation as a unary operator.

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