The problem of dynamic inheritance

cyberbaixing cyberbaixing at yahoo.com.cn
Wed Jan 14 23:26:13 UTC 2004


Dear Jecel,

Thank you for your receipt. 
May I understand the whole procedure in this way?

The object a is a parent of c. When I send a message f to object c, 
after implements the 'c' printLine, due to the resend.f message, 
Lookup will look at its parent to run f. Since a has a method f, f is 
implemented. Furthermore, a also defines "change to a new parent 
named b" in method f. Because object c right has a slot b, so a's 
definition can work on c, finally c changes its parent to b and 
implement resend.f again.

I add a new object d which is almost same as b in the original 
program, and I set d as the parent of a. I want to test whether I can 
get 'b' when I send a f.
a _Define: (|
        p*<-d.
        f = ('a' printLine. p:b. f).
|)
 
b _Define: (|
        f = ( 'b' printLine ).
|)
 
c _Define: (|
        p1*<- a.
        b =b.
        f = ('c' printLine. resend.f).
|)
 
d _Define: (|
        f = ('d' printLine. ).
|)

The output of a f has no change.
But when I send a message: c f, I get infinite output of a and c like:
...
a 
c 
a
c
...
till the stack overflows :P. I don't understand why object c falls 
into the endless output if I only add a parent to object a? 

I go on with adding a slot b =b. in object a. I still want to see 
whether I can see the output of 'b' by sending message "a f". The 
object a changes to this form:
a _Define: (|
        p*<-d.
        b =b.
        f = ('a' printLine. p:b. f).
|)
Too bad, the result of a f. also changes to endless output of a!
...
a 
a
a
a
... till the stack overflows. Would you please tell me why?

Thanks,
Xing





More information about the Self-interest mailing list