You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Re: integer negation, the issue can be resolved within the Go implementation with no change to the language. Having said that, unary negation is indeed a standard arithmetic operator.
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 parsing200-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.The text was updated successfully, but these errors were encountered: