Open nilslice opened 2 years ago
The original reason for not allowing INTEGER
values there is because different implementations of Quil might represent integers in different ways. For example, different schemes for signed fixed-precision numbers. I didn't want to require any specific width or bit-layout to integers.
There is a way in Quil to allow for this implementation-dependent behavior though; it's to use octet aliasing. Assuming INTEGER
values are 16-bit unsigned integers, one could do:
DECLARE xs OCTET[2]
DECLARE ys OCTET[2]
DECLARE x INTEGER SHARING xs
DECLARE y INTEGER SHARING ys
AND xs[0] xs[0] ys[0]
AND xs[1] xs[1] ys[1]
This would be the C equivalent of
uint16_t x, y;
x &= y;
While working on a parser implementation in
quil-rust
, it struck me that theINT
alternative of the right-hand operand in a logical binary operation could possibly be further specified & wanted to get some thoughts. For reference:BIT
definition which would reduce the range of values to1
or0
? @kalzoo mentioned we can (maybe already do?) coerce anINT
when needed so maybe this isn't necessary.