From: <no...@so...> - 2001-05-10 20:57:09
|
Bugs item #231259, was updated on 2001-02-06 06:43 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=110894&aid=231259&group_id=10894 Category: [namespace] >Group: 8.4a3 Status: Open Resolution: None Priority: 3 Submitted By: miguel sofer (msofer) Assigned to: miguel sofer (msofer) >Summary: shadowing byte-compiled commands Initial Comment: According to the comments for the function TclResetShadowedCmdRefs in generic/tclNamesp.c the following should not happen: % #define a namespace proc that uses the global command 'set' % namespace eval mig {proc test {} {set ::g 0}}; mig::test 0 % % #define a namespace proc 'set' that shadows the global command; % #the previously compiled 'test' never notices! % namespace eval mig {proc set {a b} {::set a [incr b]}}; mig::test 0 % #>>>>>>>>>>> % #? Shouldn't the namespace epoch have been bumped up by the % #shadowing, ? so that all procs are recompiled? % #>>>>>>>>>>> % % #if I redefine, and hence force recompilation of 'test', it is ok.) % namespace eval mig {proc test {} {set ::g 0}}; mig::test 1 ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2001-05-10 13:50 Message: Logged In: YES user_id=148712 Sorry about that "second example"; it is only an example of how stupid one gets when doing things in haste ... No bug in that situation if programmed correctly: the redefinition of 'mySet' should have a body {uplevel set $var [expr $val + 1]} and then things work out as they should ... ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2001-05-10 12:14 Message: Logged In: YES user_id=148712 A different aspect of the same bug is shown by the example: % namespace export set namespace eval mig { namespace import ::set rename set mySet proc test {a} { variable var mySet var $a } test 0 set var0 $var rename mySet {} proc mySet {var val} { set $var [expr $val + 1] } test 0 set var1 $var puts "$var0 $var1" } % 0 0 ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2001-02-07 13:16 Message: No, I'm not ... ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2001-02-07 12:25 Message: I am submitting a patch to tclProc.c that fixes this. ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2001-02-07 10:35 Message: It seems to be a deeper bug; some global commands (eg, set) are compiled directly to bytecode. Commands that shadow *them* are immune to the implementation of the 'reset on shadowing': it invalidates command *references* in the bytecode, but there is no command reference to 'set' in there! Maybe shadowing should force recompilation of the proc, and not just a fresh resolution of command names? In that case, a small patch to TclProcCompileProc (generic/tclProc.c) would arrange it. ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2001-02-06 08:06 Message: Sorry for the title, it is way too specific and maybe misleading! A correct title would be * Incorrect command scoping * I do not actually know if, in the example above, cmdRefEpoch was not updated, or if it was but the bytecompiler ignored it. msofer ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=110894&aid=231259&group_id=10894 |