-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.eva
More file actions
45 lines (32 loc) · 845 Bytes
/
test.eva
File metadata and controls
45 lines (32 loc) · 845 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
45
/**
* Class declaration.
*/
(class Point null
(begin
(var (x number) 0)
(var (y number) 0)
(def constructor ((self Point) (x number) (y number)) -> Point
(begin
(set (prop self x) x)
(set (prop self y) y)
self))
(def calc ((self Point)) -> number
(+ (prop self x) (prop self y)))))
(var (p Point) (new Point 10 20))
((prop p calc) p)
/**
* Child class.
*/
(class Point3D Point
(begin
(var (z number) 0)
(def constructor ((self Point3D) (x number) (y number) (z number)) -> Point3D
(begin
((prop (super Point3D) constructor) self x y)
(set (prop self z) z)
self))
(def calc ((self Point3D)) -> number
(+ ((prop (super Point3D) calc) self)
(prop self z)))))
(var (p Point3D) (new Point3D 10 20 30))
((prop p calc) p)