| 1 |
#include <tads.h> |
| 2 |
|
| 3 |
property propNotDefined; |
| 4 |
export propNotDefined; |
| 5 |
|
| 6 |
main(args) |
| 7 |
{ |
| 8 |
local x = new C(new B()); |
| 9 |
|
| 10 |
"x.p1...\n"; |
| 11 |
x.p1(100); |
| 12 |
|
| 13 |
"\bx.p2\n"; |
| 14 |
x.p2(200); |
| 15 |
} |
| 16 |
|
| 17 |
class A: object |
| 18 |
p1(x) { "This is A.p1(<<x>>)\n"; } |
| 19 |
p2(x) { "This is A.p2(<<x>>)\n"; } |
| 20 |
; |
| 21 |
|
| 22 |
class B: A |
| 23 |
p1(x) { "This is B.p1(<<x>>) - inheriting...\n"; inherited(x+1); } |
| 24 |
; |
| 25 |
|
| 26 |
class C: object |
| 27 |
construct(b) { baseobj = b; } |
| 28 |
baseobj = nil |
| 29 |
|
| 30 |
propNotDefined(prop, [args]) |
| 31 |
{ |
| 32 |
"This is C.propNotDefined - delegating to base object...\n"; |
| 33 |
return baseobj.(prop)(args...); |
| 34 |
} |
| 35 |
; |
| 36 |
|
| 37 |
modify C |
| 38 |
p1(x) { "This is mod-C.p1(<<x>>) - inheriting...\n"; inherited(x+1); } |
| 39 |
|
| 40 |
propNotDefined(prop, [args]) |
| 41 |
{ |
| 42 |
"This is mod-C.propNotDefined - inheriting...\n"; |
| 43 |
return inherited(prop, args...); |
| 44 |
} |
| 45 |
; |
| 46 |
|