Feature Request: Bitwise operators on integers in gsbasic

Started by jaymzjulian, November 13, 2019, 06:46:39 PM

Previous topic - Next topic

jaymzjulian

Logical operators are true/false only, but it'd be nice to do something like:

' between 0 and 7
a = a & 7
' set bit 4
a = a | 4

when doing things like dealing wth the AY particularly, of course :).  Maybe use the C-style operators of &/|/^, since the letter ones already have clear meaning that should not be changed under people :)

Vectrex32


Vectrex32

Oops ... ^ is already being used for exponents. I could have an 'xor' operator, but that's going to mess people up. Everyone who sees & and | is going to expect ^ for xor, and they're going to be plenty confused if they get an exponent.

- Bob

Vectrex32

Meanwhile, AND and OR do short-circuit evaluation in IF statements, so I can't use them as bitwise operators. Visual Basic solves this by using AndAlso and OrElse for short circuit evaluation. But for me to do it Visual Basic's way would be a breaking change to the V32.

:-( :-(

- Bob