-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseq_demo.mapal
More file actions
36 lines (33 loc) · 1.16 KB
/
Copy pathseq_demo.mapal
File metadata and controls
36 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// seq_demo.mapal
//
// Demonstrates: `seq { … }` as a STATEMENT BLOCK (ADR-0019), the sibling of
// fanout.mapal. A pure parallel fanout computes two values concurrently; after
// the implicit join, a `seq` block prints them in a GUARANTEED order.
// `println` is effectful and would be rejected inside the *parallel* fanout
// (E2) — but `seq` is the legal, sequential effect site. The ordering
// guarantee IS the IoToken thread that statement-order lowering produces
// (ADR-0019 pin d): `seq` has no IR node of its own.
//
// Inside the block: the headless chain `-> println` seeds from the seq input
// (pin a); `db -> println` reads a binding from the enclosing scope (pin b).
//
// Expected output (interpreted), for input 6:
// 36
// 12
fn square(x: i32) -> i32 {
x * x -> ret;
}
fn double(x: i32) -> i32 {
x * 2 -> ret;
}
fn main() {
6 -> {
-> square -> sq;
-> double -> db;
}
// implicit join: (sq, db) both available. `seq` forces the two prints in order.
sq -> seq {
-> println; // seeds from the seq input (sq) → 36
db -> println; // enclosing-scope binding → 12
}
}