[Xotcl] Help with Filters. Resubmission.
Uwe Zdun
uwe.zdun at uni-essen.de
Mon Dec 17 17:40:01 CET 2001
The problem below is that a filter (like a mixin) is only called if a method
to be dispatched exists for an object ... maa does not exist for A's objects,
therefore, the filter is not called, but unknown is called. The standard
unknown raises the error here. You can test this by adding a custom unknown
to A (of course you can also handle the delegation in unknown):
A instproc unknown args {
puts "unknown $args --> error"
next
}
On Saturday 15 December 2001 16:28, Sheik Yussuff wrote:
> Below is nonsensical sample code to illustrate a problem I
> am having with filters. On invocation of:
> a mb (see code section below)
> 1. Object a is sent the message mb(not an instproc) of A
> 2. Filter af of object a intercepts and
> dispatches message mbb to object b
> 3. Filter bf of object b intercepts and
> redispatches message maa to object a
> This time the filter af does not intercept message maa!!
> The message maa is sent directly to object a with
> the resulting error: object a unable to dispatch
> method maa.
>
> Can anyone assist me in explaining what is happening here?
> ------------------------------------------------------------
> #Code: Win 98 version 0.91; got same problem with ver 0.85 3 months ago.
>
> Class A -parameter {delegate}
>
> A instproc af args {
> set method [self calledproc]
> if {[[self] exists delegate]} {
> set del [[self] set delegate]
> if {$method == "maa"} {
> return [eval $del mbb]
> }
> if {$method != "ma"} {
> return [eval $del $method $args]
> }
> }
> next
> }
>
> A instfilter {af}
>
> A instproc ma args {
> puts "method ma of A"
> }
>
>
> Class B
> B instproc bf args {
> set sender [self callingobject]
> set method [self calledproc]
> puts "method is: $method"
> if {$method == "mb"} {
>
> return [eval $sender maa]
> }
> next
> }
>
> B instfilter bf
>
> B instproc mb args {
> puts "method mb of B"
> }
>
> B instproc mbb args {
> puts "method mbb of B"
> }
>
> B b
> A a
> a delegate b
> #a ma ; #works ok
> a mb
>
>
>
> _______________________________________________
> Xotcl mailing list - Xotcl at alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
--
Uwe Zdun
Institute for Computer Science, University of Essen
Phone: +49 201 81 00 332, Fax: +49 201 81 00 398
zdun@{xotcl,computer,acm}.org, uwe.zdun at uni-essen.de
More information about the Xotcl
mailing list