# OBJECT introduce method handler wrappers
[hear] (define add-method /
lambda (object name method)
(hash-add
(object)
(name)
(? dummy /
method /
object)));
[hear] (define call / ? x / x 0);
[hear] (define test-struct2 /
mutable-struct /
vector x y);
[hear] (set! (test-struct2 x) 10);
[hear] (set! (test-struct2 y) 20);
[hear] (= (get! / test-struct2 x) 10);
[hear] (= (get! / test-struct2 y) 20);
[hear] (define test-struct3 /
add-method
(test-struct2)
sum
(? self /
+ (get! / self x) (get! / self y)));
[hear] (= (get! / test-struct3 x) 10);
[hear] (= (get! / test-struct3 y) 20);
[hear] (= (call / test-struct3 sum) 30);
[hear] (set! (test-struct3 y) 10);
[hear] (= (call / test-struct3 sum) 20);
[hear] (set! (test-struct2 y) 5);
[hear] (= (call / test-struct3 sum) 15);