1 ## our_shell: ysh
2
3 #### Object() creates prototype chain
4
5 func Rect_area(this) {
6 return (this.x * this.y)
7 }
8
9 var Rect = {area: Rect_area}
10
11 var rect1 = Object(Rect, {x: 3, y: 4})
12 var rect2 = Object(Rect, {x: 10, y: 20})
13
14 # This could change to show the object?
15 # pp test_ (rect)
16
17 # TODO: This should be a bound function
18 #pp asdl_ (rect)
19 #pp (rect.area)
20 #pp (rect->area)
21
22 var area1 = rect1.area()
23 var area2 = rect2.area()
24
25 echo "area1 = $area1"
26 echo "area2 = $area2"
27
28 ## STDOUT:
29 area1 = 12
30 area2 = 200
31 ## END