Tcl Source Code

View Ticket
Login
Ticket UUID: b2964460b617adb8399bc67ca691e1039b49bd0b
Title: persistent namespace import: routine resolution when target routine is deleted and recreated
Type: RFE Version:
Submitter: pooryorick Created on: 2019-01-09 00:18:54
Subsystem: 21. [namespace] Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2019-01-09 11:01:38
Resolution: None Closed By: nobody
    Closed on:
Description:

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.

User Comments: sebres added on 2019-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).


sebres added on 2019-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.