-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 stabilised syntax for OpenQASM 3 switch
#11417
Conversation
The OpenQASM 3 project made some changes to the preliminary syntax of the `switch` statement, merging the final version in openqasm/openqasm#463. This commit adds support for the new syntax, making it available by default while still supporting the experimental flag to enable the preliminary syntax. Support for the old flag is necessary to allow Qiskit to continue to interoperate with other tooling that still assumes the preliminary format (we know that at least the IBM QSS compiler is in this position right now), and in general should hopefully not be too onerous to continue to support.
One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 7732196831Warning: This coverage report may be inaccurate.We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, just one 🇬🇧 nit inline. The other thing is the name of the statement class for the experimental version. But both are fairly minor.
Co-authored-by: Matthew Treinish <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I caught some 🇬🇧 "stabilised" in the release note, but we can just fix that in the release note round-up for the final release. Thanks for the quick update.
:mod:`qiskit.qasm3`) now supports the stabilised syntax of the ``switch`` statement in OpenQASM 3 | ||
by default. The pre-certification syntax of the ``switch`` statement is still available by | ||
using the :attr:`.ExperimentalFeatures.SWITCH_CASE_V1` flag in the ``experimental`` argument of | ||
the exporter. There is no feature flag required for the stabilised syntax, but if you are | ||
interfacing with other tooling that is not yet updated, you may need to pass the experimental | ||
flag. | ||
|
||
The syntax of the stabilised form is slightly different with regards to terminating ``break`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:mod:`qiskit.qasm3`) now supports the stabilised syntax of the ``switch`` statement in OpenQASM 3 | |
by default. The pre-certification syntax of the ``switch`` statement is still available by | |
using the :attr:`.ExperimentalFeatures.SWITCH_CASE_V1` flag in the ``experimental`` argument of | |
the exporter. There is no feature flag required for the stabilised syntax, but if you are | |
interfacing with other tooling that is not yet updated, you may need to pass the experimental | |
flag. | |
The syntax of the stabilised form is slightly different with regards to terminating ``break`` | |
:mod:`qiskit.qasm3`) now supports the stabilized syntax of the ``switch`` statement in OpenQASM 3 | |
by default. The pre-certification syntax of the ``switch`` statement is still available by | |
using the :attr:`.ExperimentalFeatures.SWITCH_CASE_V1` flag in the ``experimental`` argument of | |
the exporter. There is no feature flag required for the stabilized syntax, but if you are | |
interfacing with other tooling that is not yet updated, you may need to pass the experimental | |
flag. | |
The syntax of the stabilized form is slightly different with regards to terminating ``break`` |
class SwitchStatement(Statement): | ||
"""AST node for the proposed 'switch-case' extension to OpenQASM 3.""" | ||
class SwitchStatementPreview(Statement): | ||
"""AST node for the proposed 'switch-case' extension to OpenQASM 3, before the syntax was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to think of a better more useful name than ....Preview
. I think contemporary software devs find the word "Legacy" distasteful. But it's probably widely understood by casual programmers. Maybe SwitchStatementOldStyle
. In OQ3, "old style" refers to OQ2 legacy syntax. In this case it's not from a previous version. But OldStyle
tells me that I probably don't want this, even if I am not familiar with its history.
Or even SwitchStatementObsolete
. This really tells me I should not be using it.
Summary
The OpenQASM 3 project made some changes to the preliminary syntax of the
switch
statement, merging the final version in openqasm/openqasm#463. This commit adds support for the new syntax, making it available by default while still supporting the experimental flag to enable the preliminary syntax. Support for the old flag is necessary to allow Qiskit to continue to interoperate with other tooling that still assumes the preliminary format (we know that at least the IBM QSS compiler is in this position right now), and in general should hopefully not be too onerous to continue to support.Details and comments
The new syntax won't be supported by the QSS compiler yet, and there's no need to rush to that - it's easy for Qiskit to continue to support both, and having an easy flag switch over means that any deployments of Qiskit alongside other OpenQASM 3 parsers can easily keep them in sync without having to fall behind on Qiskit bugfixes.