Skip to content

Commit

Permalink
Update release note.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhartman committed Feb 26, 2025
1 parent e902009 commit 16475c3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions releasenotes/notes/const-expr-397ff09042942b81.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
features_circuits:
- |
The classical realtime-expressions module :mod:`qiskit.circuit.classical` can now represent
constant types and operations on them. All :class:`~.types.Type` classes now have a bool
:attr:`~.types.Type.const` property which is used to mark const-ness and enforce const
invariants across the types system.
constant expressions. The :class:`~.expr.Expr` class now has a bool
:attr:`~.expr.Expr.const` attribute which indicates the expression's const-ness. This allows
us to enforce that expressions in certain contexts must be possible to evaluate at compile-time.
To create a const value expression use :func:`~.expr.lift`, setting ``try_const=True``::
All :class:`~.expr.Var` expressions are considered to be non-const, while all :class:`~.expr.Value`
expressions are const.
An expression comprised only of other const expressions is also const::
from qiskit.circuit.classical import expr
expr.lift(5, try_const=True)
# Value(5, Uint(3, const=True))
expr.bit_and(5, 6).const
# True
The result type of an operation applied to const types is also const::
An expression that contains any non-const expression is non-const::
from qiskit.circuit.classical import expr
from qiskit.circuit.classical import expr, types
expr.bit_and(expr.lift(5, try_const=True), expr.lift(6, try_const=True)).type.const
# True
expr.bit_and(5, expr.Var.new("a", types.Uint(5)).const
# False

0 comments on commit 16475c3

Please sign in to comment.