-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall.echo
More file actions
48 lines (39 loc) · 700 Bytes
/
Copy pathcall.echo
File metadata and controls
48 lines (39 loc) · 700 Bytes
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
37
38
39
40
41
42
43
44
45
46
47
48
; Call / result overhead — real tiny helpers + normal benches.
; Run: xo run examples/algos/call.echo
/ std/io
/ std/str
/ std/test
$ empty = () {
^ 0
}
$ identity = (x) {
^ x
}
; Result-shaped ok (both ^ and ! present → result ABI).
$ ok_value = () {
^ 42
! "unused"
}
io.print(str.from_int(empty()))
io.print(str.from_int(identity(7)))
| ok_value() {
$ v {
io.print(str.from_int(v))
}
! e {
io.print(e)
}
}
test.bench("empty_call", () {
$ x = empty()
})
test.bench("identity_call", () {
$ x = identity(1)
})
test.bench("result_ok_match", () {
| ok_value() {
$ v {}
! e {}
}
})
\ empty, identity, ok_value