-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify spelling of the bit
literal
#534
Comments
It may make life easier to declare the scalar |
OQ3 is already liberal with implicit casting. Sticking with that tendency, I'd say that both c[0] = 1;
c[0] = true; work and have the same semantics. But I say this after thinking about it for 60s.
You mean a scalar and a bit array of length one? Those should definitely be distinct types, right? |
I'm not sure where I stand, but to throw out another option, we could also introduce single-quote strings for bit literals, e.g. a As for the distinguish-ability of |
Personally I'd say strongly yes, but there's arguments to be made along the vein of implicit casts and "what does |
Blake:
Does it for sure? In #535 I was giving examples of how I'm not entirely sure that it actually does, when it comes to broadcasting - at the very least, it'd be good to clarify it in the spec one way or the other. The short form of my question is, given: include "stdgates.inc";
qubit[2] a;
qubit[2] b;
cx a[0:0], b[0:1]; where |
What is the expected enhancement?
We have a spelling for
bool
literals (false
andtrue
) and a spelling for bitstrings ("00101"
forbit[5]
), but it's not clear to me from the spec what the spelling of a single scalarbit
value is.bit[1]
would be the strings"0"
or"1"
andbool
is listed as explicitly casting to that, so can we clarify thatbool
can implicitly cast tobit
(the scalar, not the family) and use the Boolean literals forbit
? Alternatively, the integer literals 0 and 1 forbit
.My motivation is that I need to know the literal syntax to spell setting a single bit out of a larger integer, like:
A related point is whether
bit
andbit[1]
actually are distinct types. My type-theory purism likes them to be distinct, but that's mostly philosophical. For sure it feels easier to implement the type system like that to me, and it makes it easier to talk about broadcasting inmeasure
.The text was updated successfully, but these errors were encountered: