summaryrefslogtreecommitdiff
path: root/tests/use.toc
blob: f1228f6aac0dd96cf52f9134d68d92339bf8eecc (plain)
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
#include "io.toc", io;
#include "mem.toc", mem;

use mem;

Point ::= struct {	
	x: int;
	y: int;
	a ::= 3;
}

make_point ::= fn (x_: int, y_: int) use p: Point {
	x = x_+a;
	y = y_+a;
}

main ::= fn() {

	use io;

	{
		use p: Point;
		use io;
		x = 5;
		puti(x);
	}



	ps := news(Point, 5);
	for p := &ps {
		*p = make_point(3, 5);
	}
	for use p, i := &ps {
		x += i;
		y += 2*i;
	}
	for use p := ps {
		writei(x);
		writes(" ");
		writei(y);
		puts("");
	}
	dels(ps);
}