Hello Gustaff,
I am having a problem with unknown in NX, where, if I define my own "unknown" method, in which I just check for presence of some argument, if that argument does not exist, I pass processing further on via [next] to the built-in "unknown" processor, well, at least that's what I would like to do. What I find is that there is no further processing done, [next] does not do anything, the unknown method just returns silently. Am I doing something wrong?
########################################## Class create C C method unknown args { if {$args eq "test"} { puts "found test"; return }; next; }
C create obj; obj test
found test
obj xyz
#nothing, no error
############################################ Thanks,
Victor
Victor,
Am I doing something wrong?
No, what you scripted is perfectly fine (by intention), you just revealed a collateral (in my understanding):
Right now, there is no ::nx::Object->unknown() defined, which would be the [next] target. Therefore, [next] does not give you what you expect. If you look in nx.tcl, it is simply commented out.
In the commit http://fisheye.openacs.org/changelog/xotcl/?cs=//xotcl/67ad561b71e208451454f... changes where applied to make a scripted unknown method on the root class (::nx::Object) unnecessary. however, these changes do not cover the case of refining this built-in unknown "method".
a quick workaround for the scope of your application is to define ::nx::Object->unknown() at an early stage:
::nx::Object protected method unknown {m args} { error "[::nsf::self]: unable to dispatch method '$m'" }
or simply signal the error in your application-level unknown:
C method unknown {m args} { if {$args eq "test"} { puts "found test"; return } error "[::nsf::self]: unable to dispatch method '$m'" }
for an authorative fix i would need to understand why these changes happened in the first place which i don't, frankly. was the intention to remove unknown from ::nx::Object method record entirely? i hope not ... but gustaf is the authority here.
//stefan
Thank you Stefan. That clarifies it.
On Fri, Feb 18, 2011 at 3:58 AM, Stefan Sobernig stefan.sobernig@wu.ac.at wrote:
Victor,
Am I doing something wrong?
No, what you scripted is perfectly fine (by intention), you just revealed a collateral (in my understanding):
Right now, there is no ::nx::Object->unknown() defined, which would be the [next] target. Therefore, [next] does not give you what you expect. If you look in nx.tcl, it is simply commented out.
In the commit http://fisheye.openacs.org/changelog/xotcl/?cs=//xotcl/67ad561b71e208451454f... changes where applied to make a scripted unknown method on the root class (::nx::Object) unnecessary. however, these changes do not cover the case of refining this built-in unknown "method".
a quick workaround for the scope of your application is to define ::nx::Object->unknown() at an early stage:
::nx::Object protected method unknown {m args} { error "[::nsf::self]: unable to dispatch method '$m'" }
or simply signal the error in your application-level unknown:
C method unknown {m args} { if {$args eq "test"} { puts "found test"; return } error "[::nsf::self]: unable to dispatch method '$m'" }
for an authorative fix i would need to understand why these changes happened in the first place which i don't, frankly. was the intention to remove unknown from ::nx::Object method record entirely? i hope not ... but gustaf is the authority here.
//stefan