Typed classical values
Design document · English reading edition
RFCs record designs and changes. A proposal appearing here does not mean its feature is ready to use. Explore current language support
Status recorded in the original: Runtime experimental
Bound original source · SHA-2568c5811cb9f44707de4bee907fbc40c42fd27f69e14504fdef008030fff0b9cc4
Reading edition reviewed: 2026-10-02
Purpose and scope
Adds a bounded, typed, immutable value layer between measurement and classical computation. Aggregating measured bits and making conversions explicit avoids relying on incidental JavaScript coercion.
Core design rules
- Fixed-size arrays and bit vectors carry an element type and a declared length.
- Conversions from bits to numerical values use explicit operations; type labels are not merely comments.
- AST, runtime and result evidence must retain the same type information.
Example from the original
This example illustrates the design recorded in the original. It is not by itself a claim of executable or stable support; check required options and the current version.
module typed_measurement_summary;
@seed(17);
fn main() {
let q: QReg<3> = qreg[3];
H(q[0]);
CNOT(q[0], q[1]);
let a: Bit = measure(q[0]);
let b: Bit = measure(q[1]);
let c: Bit = measure(q[2]);
let outcomes: Array<Bit, 3> = [a, b, c];
let encoded: Int = bits_to_int(outcomes);
let ones: Int = count_ones(outcomes);
let ratio: Float = int_to_float(ones) / 3.0;
let weights: Array<Float, 3> = [1.0, 2.0, 3.0];
let average: Float = mean(weights);
return encoded;
}Limits and interpretation
- Runtime-growing collections and general mutable memory are outside this slice.
- A classical value after measurement does not represent the complete pre-measurement quantum state.
Status and implementation boundary
The source describes a runtime-experimental value contract. Read NM-RFC-0035 and the current guides separately for classical helpers and subsequent numeric additions.
| Review topic | Information to check |
|---|---|
| Source revision | SHA-256 digest bound to this reading edition |
| Availability | Current capability record and tool options |
| Evidence boundary | Model, size and interpretation limits above |