[595] in Coldmud discussion meeting
Re: A subtle ingeritence question.
daemon@ATHENA.MIT.EDU (Fri Nov 25 02:56:54 1994
)
From: deforest@netcom.com (Robert de Forest)
To: jeffpk@netcom.com (Jeff Kesselman)
Date: Thu, 24 Nov 1994 23:51:53 -0800 (PST)
Cc: coldstuff@MIT.EDU
In-Reply-To: <199411250637.WAA21336@netcom16.netcom.com> from "Jeff Kesselman" at Nov 24, 94 10:37:38 pm
>
> This is a fairly sublte question regarding inheritence:
>
> Object A
> has method foo
> has method bar which calls foo
>
> Object B
> is a child of Object A
> has method foo
>
> B.bar() will call WHICH foo when invoked?
>
> Thanks
>
> Jeff kesselman
>
>
>
I'll define the problem more exactly:
;$root.spawn().set_name('A)
;$A.spawn().set_name('B)
@program $A.foo
arg [args];
return [sender(), caller(), definer(), this(), 'foo, args];
.
@program $A.bar
arg [args];
.foo(sender(), caller(), definer(), this(), 'bar, args);
.
;$B.compile($A.list_method('foo), 'foo)
;; // :)
;$B.bar()
=> [$B, $A, $B, $B, 'foo, [$crag, $crag, $A, $B, 'bar, []]]
THe answer is B's foo will be called. Method searches look for method which is
closest to the this, or the farthest disallow_overides definition. If A.foo
had been dis_over it would have been called instead. I believe the manual
covers this just fine.