Namespace import behaves strange when redefining commands
Closed1585064fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 18 years ago
Descriptionplain2006-10-26 12:49:32
When executing the following script:
namespace eval debug {
namespace export breakpoint
proc on {} {proc breakpoint {{s {}}} {puts on}}
proc off {} {proc breakpoint args {}}
off
}
namespace import ::debug::*
::debug::on
breakpoint
No ouptut is shown while I expected on to be shown.
when forcing reimport of the breakpoint proc with
namespace import -force ::debug::*
on is displayed for subsequent calls to breakpoint
also when using the FQN ::debug::breakpoint on is
displayed.
When the off proc is defined as:
proc off {} {proc breakpoint args {return}}
It works as expected.
dgpplain2006-10-26 20:53:04
Logged In: YES user_id=80530 [09:49]dgpdo look at [control::assert] for how to do what I guess you are trying to do. [09:49]kbk checks into the chat. [09:49]dgpbut yes imports follow renames [09:50]dgpin the 8.0 timeframe this was considered a good thing [09:51]dgpmostly forced in as an arranged marriage to make "snapshot semantics" of [namespace import] live with autoloading of package commands. [09:51]dgpAIUI
dgpplain2006-10-26 20:54:52
Logged In: YES user_id=80530 I wrote "follows renames" but of course the issue here is "follows redefinitions". Sorry.
pcmacdonplain2007-10-18 10:24:02
Logged In: YES
user_id=190660
Originator: NO
Not sure if this helps,
but one workaround is to avoid the NOOP optimization
by using a non-'args' signature or non-empty body on redefining
an import.
ie.
proc breakpoint {{s {}}} {}
or
proc breakpoint {args} {;}
msofer Pending ticket [1585064fff].
[History diff]2008-07-30 06:56:16
sf-robotplain2008-08-13 09:20:28
Logged In: YES user_id=1312539 Originator: NO This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.