← demo0xc065ed…6075Succeededblock 90
No position yet0 / 34
FetchingOpeningPositioning
noir
Narrow session: Code, Call Trace and Values only, read-only. The event log and stepping need a wider viewport.
Code
1 seed = "5"
2 scale = "1000"
1 // TOUR: types and values
2 //
3 // Every value kind this language has, brought into scope one line at a time so
4 // the state pane has something of each to render. Nothing here computes
5 // anything interesting on purpose — the subject IS the values, and a reader
6 // stepping through should be able to name the type of every row they see.
7
8 struct Vec2 {
9 x: Field,
10 y: Field,
11 }
12
13 struct Body {
14 label: str<6>,
15 position: Vec2,
16 mass: u32,
17 alive: bool,
18 }
19
20 fn main(seed: Field, scale: pub u32) -> pub Field {
21 // ── the field element, this language's native scalar ──────────────────
22 let field_value: Field = seed + 17;
23
24 // ── unsigned integers, four widths ────────────────────────────────────
25 let small: u8 = 200;
26 let medium: u16 = 40_000;
27 let wide: u32 = scale;
28 let widest: u64 = 9_000_000_000;
29
30 // ── signed integers, which print with a sign and wrap differently ─────
31 let negative: i8 = -42;
32 let signed_wide: i32 = -100_000;
33
34 // ── the boolean, and a string of fixed length ─────────────────────────
35 let flag: bool = small > 100;
36 let name: str<6> = "cosmos";
37
38 // ── a fixed-size array, indexed and read back ─────────────────────────
39 let weights: [u32; 4] = [3, 1, 4, 1];
40 let third = weights[2];
41
42 // ── a tuple, which the state pane renders positionally ────────────────
43 let pair: (Field, bool) = (field_value, flag);
44
45 // ── a struct, and a struct nested inside another struct ───────────────
46 let origin = Vec2 { x: 0, y: 0 };
47 let body = Body { label: name, position: Vec2 { x: 3, y: 4 }, mass: wide, alive: flag };
48
49 // ── a vector, whose length grows at run time rather than being fixed
50 // by the type the way `weights` above is ─────────────────────────────
51 let mut trail: [Field] = [body.position.x].as_vector();
52 trail = trail.push_back(body.position.y);
53 trail = trail.push_back(origin.x);
54
55 // ── a value read back out of each compound, so the step that reads it
56 // has a scalar to show next to the compound it came from ────────────
57 let from_array = weights[0] + third;
58 let from_tuple = pair.1;
59 let from_struct = body.position.y;
60 let from_slice = trail[1];
61
62 assert(from_array == 7);
63 assert(from_tuple == flag);
64
65 // Signed values reach `Field` only through an unsigned width — the
66 // language refuses the direct cast, which is itself worth seeing written
67 // down once.
68 let signed_gap: i32 = negative as i32 - signed_wide;
69 let signed_gap_u: u32 = signed_gap as u32;
70
71 let total = field_value
72 + from_struct
73 + from_slice
74 + medium as Field
75 + widest as Field
76 + signed_gap_u as Field;
77
78 total
79 }
1 [package]
2 name = "tour_values"
3 type = "bin"
4 authors = ["BlockTracer capability tour"]
5
6 [dependencies]
Event Log

The recorded event stream is in the published recording. Reading it needs the replay engine, which this page has not started.

Call Trace

The call structure is in the published recording. Reading it needs the replay engine, which this page has not started.

Values

The recorded values are in the published recording. Reading them needs the replay engine, which this page has not started.