[TCLCORE] Re: [Xotcl] TIP #257: Object Orientation for Tcl
Donal K. Fellows
donal.k.fellows at manchester.ac.uk
Thu Sep 29 01:04:13 CEST 2005
Gustaf Neumann wrote:
> Donal K. Fellows schrieb:
>> BTW, I was wondering what happens when you do this in XOTcl (ignoring
>> the syntax for now):
>>
>> class A derived from Object
>> defines instproc foo
>> class B derived from A
>> defines instproc bar
>> class C derived from Object
>> defines instprocs foo, bar and move
>>
>> object D is a C with B mixed in
>> call: D foo
>> call: D move
>>
>> Which implementation of foo gets called first? Which implementation of
>> move gets called first?
>
> as kristoffer pointed out, there is only one move, so there is no
> ambiguity.
There are two 'move' methods/instprocs. One is in the XOTcl base Object
class, and one is in C.
> In general the precedence order is
> per-object-mixins per-class-mixins self-procs class-hierarchy
>
> The introspection command for this is
> D info precedence
Perhaps I should explain more about what I was asking about. :-)
What I did was I constructed the situation according to the attached
diagram (sorry to everyone for doing an attachment, but I refuse to do
ASCII art for this!) and what I wanted to know was, given that we've got
a per-object mixin, would the foo inherited from A by B be mixed in at
higher precedence than the foo gained by D directly from C. If that's
the case, would the move inherited from Object through the mixin side
override the move gained directly from C? As far as I can tell as
someone who has not thought about this in detail, that's the only way to
do this sort of thing consistently. But it also means that mixins will
stamp all over any attempt to redefine behaviour for a particular
application domain. If I'm wrong and I've overlooked something, what is
it? It's certainly not clear to me. (Mind you, it's midnight as I write
this so the old braincells might not be producing maximum clarity
anyway. ;-) )
I hope this all explains why I was asking what appears to be on the
surface a trivial question, and the answer should clear up the details
of what I don't know about XOTcl inheritance rules from reading the
documentation.
Donal.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mixin inheritance diagram.png
Type: image/png
Size: 11074 bytes
Desc: not available
Url : http://alice.wu-wien.ac.at/pipermail/xotcl/attachments/20050929/6688b778/mixininheritancediagram-0001.png
More information about the Xotcl
mailing list