1 | use $LIB_YSH/def.ysh --pick Dict
|
2 |
|
3 | : ${LIB_OSH=stdlib/osh}
|
4 | source $LIB_OSH/byo-server.sh
|
5 |
|
6 | proc test-dict {
|
7 | var i = 0
|
8 | Dict (&d) {
|
9 | a = 42
|
10 | b = i + 1
|
11 | }
|
12 | pp test_ (d)
|
13 | }
|
14 |
|
15 |
|
16 | func Counter(start) {
|
17 | ### constructor
|
18 | var methods = Object(null, Counter_methods)
|
19 | return (Object(methods, {i: start}))
|
20 | }
|
21 |
|
22 | var Counter_methods = null
|
23 |
|
24 | # BUG: I think there is a problem with using Dict in a DIFFERENT module!
|
25 |
|
26 | if false {
|
27 | Dict (&Counter_methods) {
|
28 | #func inc(self, n) {
|
29 | # setvar self.i += n
|
30 | #}
|
31 | i = 2
|
32 | }
|
33 | }
|
34 |
|
35 | proc test-class-pattern {
|
36 | #var c = Counter(5)
|
37 | #call c.inc(5)
|
38 | :
|
39 | }
|
40 |
|
41 | if is-main {
|
42 | byo-maybe-run
|
43 | }
|