-
Notifications
You must be signed in to change notification settings - Fork 90
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
Move MResetZ to Intrinsic namespace? #1193
Comments
I agree that needing to constantly manually or via completion include qsharp/compiler/qsc_frontend/src/resolve.rs Lines 25 to 29 in 9f90eaa
That would allow users to call operations from the namespace without an explicit open in the same way they can for M , Measure , and other gate operations. The prelude is always superseded by explicitly opened namespaces or locally defined callables, so it won't change any existing code, just make future code easier, and allow any samples to be updated to remove the explicit open of the measurement namespace. The callables in the measurement namespace are:
operation MeasureAllZ (register : Qubit[]) : Result { ... }
operation MeasureEachZ (register : Qubit[]) : Result[] { ... }
operation MResetEachZ (register : Qubit[]) : Result[] { ... }
operation MResetX (target : Qubit) : Result { ... }
operation MResetY (target : Qubit) : Result { ... }
operation MResetZ (target : Qubit) : Result { ... }
operation MeasureInteger(target : Qubit[]) : Int { ... } Of these, only the last one feels a little odd to be available automatically, but even there the operation is self-contained (the implementation doesn't depend on any other utility functions as it calculates the integer directly itself rather than using any conversion functions like If no one is opposed, that would make this a one line change to the |
I'm not sure moving callables to a namespace that is already in Prelude is a breaking change, since everything from those namespaces is already open by default. (Also, I didn't realize Canon was in the prelude too... Need to go back and update some code :-) ) This approach sounds fine to me. Though now I'm wondering why we have multiple separate namespaces to store callables that are available without opening a namespace... |
It's a narrow corner case, but if anyone was using the fully qualified name,
This is definitely a good thought for our eventual module-based future (@sezna FYI). What does the prelude become and how do we reason about it when we have modules? Should everything in the prelude be in the same module or should multiple modules be in the prelude? Food for thought... Sound like the one-line change will work for now thought! |
Dumped some initial thoughts here re: prelude, as it is out of scope for this issue: #1203 |
Now that Q# requires resetting qubits to |0> before releasing them, not just measuring them, I find myself using
MResetZ
a lot more often than with the classic QDK, and every time I need to openMicrosoft.Quantum.Measurement
namespace. (There's also no Quick Fix to automate this.)Moving it to Intrinsic seems logical, since it's so frequently used in the code.
The text was updated successfully, but these errors were encountered: