-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support Qubit & Label Placeholders #147
Comments
A nice to have would be |
That seems useful. When it comes to a full function though, it would make sense for the user to just iterate over the program themselves - this resolution method is more of a convenience than a necessity, because the user will have the capability to iterate and resolve on the program directly. |
@kalzoo Just to clarify, how are we going to resolve placeholders inside of the display implementation since it would require |
This is what I had imagined, as unfortunate as that would be. Been thinking about how to be more clever about this within the existing API. Another option - resolve placeholders within each instruction as it is written, without storing them back on the program. |
Done in #266 |
pyQuil
has the capability to insert placeholders for qubits and labels into a program, andquil-rs
should support the same concept.These have no analogue in Quil itself and no serialized form, but are an aid in the construction of valid Quil programs. Both serve as a reference which defers the assignment of a concrete value until later.
Labels
A label placeholder is useful for writing portions of a program in isolation without the concern that a label will conflict with labels in other parts of the program. This is especially important for support of dynamic control flow programs. Imagine that a user may want a program with multiple loops, each of which starts with a label
@loop-start
.A label must be unique within a program, so if the user must assign a concrete label value at the time of label construction they must consider all labels already present within the program. With a placeholder, though, they can use Placeholder("loop-start") in several places, and allow the program to distinguish these prior to serialization - perhaps by adding a suffix.
Qubits
Similarly, a routine within a program may want to reference some set of qubits without yet resolving which ones those are. Like labels, this allows for qubits to be isolated to a particular scope within a program while remaining unique at the program scope.
API
Placeholders can be allocated as such:
They can then be used within the relevant enums. This will be a breaking change:
These placeholders cannot be resolved in isolation; they must be resolved within / by a Program. So add a relevant method:
The text was updated successfully, but these errors were encountered: