forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track runtime variables in control-flow builders
This adds support for all the new classical runtime variables through the control-flow builder interface. In particular, most usefully it automatically manages the scoping rules for new declarations and inner variable accesses, and ensures that its built scopes automatically close over any variables used within them (including making sure nested scopes do the same thing). The builder API is factored out a little into an explicit interface object, with `QuantumCircuit` getting an explicit implementation of that. This is done because the number of separate API methods we would have needed to pass around / infer was getting overly large, and this allows us to just use standard virtual dispatch to automatically do the right thing. Python doesn't have a way to have an object implement an interface other than by structural (duck) typing, so to avoid name leakage and collisions, we instead make `QuantumCircuit`'s implementation a friend class that handles the inner state on its behalf. Not everything control-flow-builder related is factored out into the API because it didn't seem overly useful to do this, especially when the overridden behaviour would just have been to throw exceptions.
- Loading branch information
1 parent
be31310
commit 6502ead
Showing
3 changed files
with
712 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.