Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2019-01-09
11:01 • Ticket [b2964460b6] persistent namespace import: routine resolution when target ... artifact: f77ae4f773 user: sebres
09:49 • Ticket [b2964460b6]: 4 changes artifact: 7f5537c852 user: sebres
00:18 • New ticket [b2964460b6]. artifact: 04e5bdc579 user: pooryorick

persistent namespace import: routine resolution when target routine is deleted and recreated

Openb2964460b617adb8399bc67ca691e1039b49bd0bCreated 8 years agoUpdated 8 years ago
Descriptionwiki2019-01-09 00:18:54
The following script,

	namespace eval n1 {
		namespace export *
		proc hello {} {
			puts hello
			rename hello {}
			proc hello {} {
				puts goodbye
			}
		}
	}

	namespace eval n2 {
		namespace import [namespace parent]::n1::hello
		hello
		hello
	}

produces the error invalid command name "hello".

However, if rename hello {} is removed, there is no error.

sebreswiki2019-01-09 09:49:50

I'm pretty sure we'd close this ticket (as incorrect), because this work as expected:
If you execute `rename hello {}` in-between this REMOVES also all imported links in all referenced namespaces (otherwise we'll get leaks).
Without this removal the linked command could still remain, because it is simply replaced.

sebreswiki2019-01-09 11:01:38

As discussed in tcl-chat, it looks rather like a RFE: need a way to provide a persistent import of all commands exported from other namespace.

This would affect namespace command resolver similar way like an alias (thus persistent) but only for the exported commands (therefore `namespace path`, `interp alias` etc are not an option for this purposes).

Log in (anonymous is fine) to add a comment.