1: #line 5810 "./lpsrc/flx_tutorial.pak"
2:
3:
4:
5: open Long;
6:
7: class Y[t] {
8:
9: val c : int;
10: var x : t;
11: var y : long;
12:
13:
14: fun fetchc():int =>c;
15:
16:
17: proc setx(a:t) { x = a; }
18: proc setxy( a:t, b:long) { x = a; y = b; }
19:
20:
21: proc yprint(xprint:t->0) {
22: print "This is a Y object, with x = ";
23: xprint x; print ", y = "; print y;
24: print ", and c = "; print c; endl;
25: }
26:
27:
28:
29: fun f(a:int,add:int * t->int):int => g$ a,add;
30: fun g(a:int,add:int * t->int):int => a + x;
31:
32:
33: ctor () {}
34: ctor (a:int): c(20000) { x = a; }
35: };
36:
37: var ob <- new Y[int](99);
38: ob.x = 2;
39: ob.y = 3L;
40:
41: print ob.c; endl;
42: print ob.x; endl;
43: print ob.y; endl;
44: print$ ob.fetchc(); endl;
45:
46: proc iprint(x:int) { print x; }
47:
48: ob.setx 22;
49: ob.yprint(iprint of (int));
50:
51: ob.setxy (12,33L);
52: ob.yprint(iprint of (int));
53:
54: print$ ob.f (1,add of (int*int)); endl;
55:
56: proc ncl() {
57: var x = 42;
58: class J {
59: var j:int;
60: ctor (a:int) { j = a; }
61: fun h(q:int):int => q + j + x;
62: };
63: var b <- new J(100);
64: print$ b.h 1000; endl;
65: };
66:
67: ncl;
68:
69: class A[t] {
70: fun f(a:t):t=>a;
71: ctor (){}
72: };
73:
74: module V[t] {
75: fun f(a:t):t=>a;
76: };
77:
78: fun X[t]() = {
79: fun f(a:t):t=>a;
80: }
81: var aint <- new A[int]();
1: 20000
2: 2
3: 3
4: 20000
5: This is a Y object, with x = 22, y = 3, and c = 20000
6: This is a Y object, with x = 12, y = 33, and c = 20000
7: 13
8: 1142