-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.abs
More file actions
44 lines (36 loc) · 926 Bytes
/
Copy pathcode.abs
File metadata and controls
44 lines (36 loc) · 926 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
using Count = int32;
using Counts = int32[];
using FutureRecord = Record;
using IntegerBox = Box<int32>;
namespace Domain {
using Score = int64;
}
struct Record {
public int32 value;
}
class Box<T> {
private const T value;
public Box(T initial) {
value = initial;
}
public T read() const {
return value;
}
}
Count add(const Count left, Count right) {
return left + right;
}
int32 main() {
const Count answer = add(40, 2);
Counts values = {20, 22};
FutureRecord record;
record.value = answer;
Domain.Score score = 42;
const IntegerBox* box = new IntegerBox(42);
assert(record.value == 42, "forward type alias");
assert(values[0] + values[1] == 42, "array type alias");
assert(score == 42, "namespace type alias");
assert(box.read() == 42, "generic specialization through alias");
println("absolute sample=ok");
return 0;
}