Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-08-13
09:20 • Closed ticket [1585064fff]: Namespace import behaves strange when redefining com... artifact: 72da83226b user: sf-robot
2008-07-30
06:56 • Pending ticket [1585064fff]. artifact: c060196735 user: msofer
2007-10-18
10:24 • Ticket [1585064fff]: 4 changes artifact: 195406622d user: pcmacdon
2006-10-26
20:54 • Ticket [1585064fff]: 4 changes artifact: aec0635ae8 user: dgp
20:53 • Ticket [1585064fff]: 4 changes artifact: 801fd0f512 user: dgp
12:49 • New ticket [1585064fff]. artifact: 883b4b3edc user: mpc_janssen

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.