I got a
'bad window path name ".f"
while executing
"pack .f"'
error with the following script.
package require Tk
frame .f
#rename ::.f ::_.f
proc myproc {args} {}
pack .f
The error vanished when I renamed the command (commented out line).
Can someone explain me what happened?
(I use Tk 8.4 and doz XP)
Thanks
ulis
package require Tk
frame .f
#rename ::.f ::_.f
interp alias {} ::.f {} ::myproc
I tested it and saw that, each time you invoke interp alias, it causes
the aliased proc (or widget) to be destroyed.
proc a {arg} {puts a:$arg}
proc b {arg} {puts b:$arg}
# it works
puts [info body a]
interp alias {} ::a {} ::b
# error : a is not a procedure :
info body a
Regards,
Stéphane
It's strange that interp alias destroys the aliased command.
And it remains strange that pack .f uses the .f command.
ulis
set WIDE_MAX_INT [expr {wide((1<<31)-1)}]
set wideUint [expr {wide(0)}]
proc wideUintP {a} {
if {$a<0} {
set ::wideUint [expr
{$::wideUint+$::WIDE_MAX_INT+$::WIDE_MAX_INT+2}]
interp alias {} ::wide_unsigned {} ::wideUintM
}
expr {wide($::wideUint+$a)}
}
proc wideUintM {a} {
if {$a>0} { interp alias {} ::wide_unsigned {} ::wideUintP }
expr {$::wideUint+$a}
}
interp alias {} ::wide_unsigned {} ::wideUintP
Now I can use [wide_unsigned $milli] without having to bother about
overflow anymore!
See how beautiful the two procs toggle.
And the best is, the implementation is so simple and efficient!