Mercurial > lcfOS
annotate examples/c3/types.c3 @ 303:be7f60545368
Final fixups
author | Windel Bouwman |
---|---|
date | Fri, 06 Dec 2013 12:37:48 +0100 |
parents | 158068af716c |
children |
rev | line source |
---|---|
237 | 1 |
2 /* | |
3 Demo of how to define types | |
4 */ | |
5 | |
286 | 6 module typedemo; |
237 | 7 |
8 type int A; | |
9 type int B; | |
10 type struct { | |
11 int x, y; | |
12 A z; | |
13 } C; | |
14 type struct { | |
15 C x; | |
16 B y; | |
17 int z; | |
18 } D; | |
19 | |
20 type D* E; | |
21 | |
22 function int testcast() | |
23 { | |
24 var A a; | |
25 var B b; | |
26 a = 3; | |
27 b = a; | |
28 var C c; | |
29 c.x = a; | |
30 c.z = c.y; | |
31 var D d; | |
32 var E e; | |
33 var D* e2; | |
34 e = &d; | |
35 e2 = e; | |
36 e2->x.x = 22; | |
37 | |
38 return 0; | |
39 } | |
40 |