1: #line 3515 "./lpsrc/flx_tutorial.pak"
2:
3: open Long;
4:
5: class Y {
6:
7: val c : int;
8: var x : int;
9: var y : long;
10:
11:
12: fun fetchc():int =>c;
13:
14:
15: proc setx(a:int) { x = a; }
16: proc setxy( a:int, b:long) { x = a; y = b; }
17:
18:
19: proc yprint() {
20: print "This is a Y object, with x = ";
21: print x; print ", y = "; print y;
22: print ", and c = "; print c; endl;
23: }
24:
25:
26:
27: fun f(a:int):int => g a;
28: fun g(a:int):int => a + x;
29:
30:
31: ctor () {}
32: ctor (a:int): c(20000) { x = a; }
33: };
34:
35: var ob <- new Y(99);
36: ob.x = 2;
37: ob.y = 3L;
38:
39: print ob.c; endl;
40: print ob.x; endl;
41: print ob.y; endl;
42: print$ ob.fetchc(); endl;
43:
44: ob.setx 22;
45: ob.yprint();
46:
47: ob.setxy (12,33L);
48: ob.yprint;
49:
50: print$ ob.f 1; endl;
51:
52: proc ncl() {
53: var x = 42;
54: class J {
55: var j:int;
56: ctor (a:int) { j = a; }
57: fun h(q:int):int => q + j + x;
58: };
59: var b <- new J(100);
60: print$ b.h 1000; endl;
61: };
62:
63: ncl;
64: