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
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)
- Object a is sent the message mb(not an instproc) of A
- Filter af of object a intercepts and dispatches message mbb to object b
- 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@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
Sorry guys. The problem as described was with ver 0.85. Version 0.91 now behaves as Uwe explained!! For ver 0.85, the behaviour as originally described (my problem) fits with the reply from Rick Hedin. Things seems to have changed from ver 0.85 to 0.91 with regards to filters - now instfilters. I prefer the previous behaviour, if I am correct with in my conception, of course. Thanks for your help. --sheik
----- Original Message ----- From: Uwe Zdun uwe.zdun@uni-essen.de To: Xotcl@alice.wu-wien.ac.at Sent: Monday, December 17, 2001 12:40 PM Subject: Re: [Xotcl] Help with Filters. Resubmission.
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)
- Object a is sent the message mb(not an instproc) of A
- Filter af of object a intercepts and dispatches message mbb to object b
- 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@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@uni-essen.de _______________________________________________ Xotcl mailing list - Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
My first explanation for this behavior from Monday was wrong ... sorry for that. In fact, the filter would filter maa ... if it is called directly (try
a maa
at the end of the program.) The reason why it is not filtered is that an active filter does not filter calls issued by itself ... a filter is active in its pre- and post part, but not during next, and only for the current object. That is, if the filter does call a method on the same object, this method call will not be filtered by that filter. If there wouldn't be such a protection, there would nearly always be endless loops during filter calls that call other methods. (Because the called filter would then issue another call to be filtered and so on and so forth). A solution for the problem below would be to provide two filters that do not mutually exclude each other, like:
A instproc af args { set method [self calledproc] if {[[self] exists delegate]} { set del [[self] set delegate] if {$method != "ma"} { return [eval $del $method $args] } } next } A instproc bf args { set method [self calledproc] if {[[self] exists delegate]} { set del [[self] set delegate] if {$method == "maa"} { return [eval $del mbb] } } next }
A instfilter {af bf}
--uwe
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@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl