Hello everyone,
I'm doing some experiment using rivet2.1rc2 and tcl8.6b3, and I'm experiencing a
different behavior in code executed under Rivet and under plain Tcl.
My need is to redefine the ::unknown command to do some magic.
If I call an non existing proc "mytest" under tclsh, I get the message saying
invalid command name "mytest"
Under Rivet, I get the equivalent message
invalid command name "mytest"
while executing
"mytest"
(in namespace eval "::request" script line 23)
invoked from within
"namespace eval request {
puts -nonewline ""
But now, I use the following code to rename ::unknown to ::_unknown,
and redefine ::unknown
to do some application specific stuff and then calling the original ::_unknown.
<?
# I need this under Rivet because the global namespace doesn't
reset among calls
# and I prevent the original ::unknown to be lost at the second execution
if { ! [llength [info commands ::_unknown]] } {
rename ::unknown ::_unknown
}
proc ::unknown {args} {
# ... do my stuff ...
# call the original unknown proc using the code seen in man page
uplevel 1 [list ::_unknown $args]
}
mytest
Of course, in the plain Tcl version I just do
rename ::unknown ::_unknown
proc ::unknown {args} {
...
}
mytest
Under plain Tcl, I get exactly the same message then before, and it's what
I expect. The uplevel stuff should put the execution of ::_unknown at the same
stack level than ::unknown, and it's a good thing, because I want to hide the
redefinition.
invalid command name "mytest"
Now, under Rivet, the message changes and is very different, because it
shows what's happening under the hood and reveals that I redefined ::unknown
and I'm doing magic:
invalid command name "mytest"
while executing
"::_unknown mytest"
("uplevel" body line 1)
invoked from within
"uplevel 1 [list ::_unknown $args]"
(procedure "::unknown" line 2)
invoked from within
"mytest"
(in namespace eval "::request" script line 21)
invoked from within
"namespace eval request {
puts -nonewline ""
Is this the right behavior? It's expected? Maybe a bug or a still not
implemented
feature?
At the end, the practical side effect is that I loose the place where
the error happens,
because it's changed from the row where "mytest" is called, to the one
in ::unknown.
This could be a deal when the "mytest" name is dynamically built, so a
text search in
the code can't help in finding the error.
I don't know whether it could create other troubles.
Bye,
Marco
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]