| Ticket UUID: | 582926 | ||
| Title: | TIP 277: create namespaces as needed | ||
| Type: | RFE | Created on: | 2002-07-17 16:48:21 |
| Submitter: | dgp | Assigned to: | dgp |
| Subsystem: | 21. [namespace] | Severity: | |
| Priority: | 8 | Last modified: | 2007-01-30 00:27:23 |
| Status: | Open | Closed by: | msofer |
| Resolution: | None | Closed on: | 2002-07-18 13:44:06 |
| Version: | None | ||
| Description: | ||||
[upvar $level $otherVar $myVar] is supposed to be able to handle a non-existent $otherVar, and mostly it does. But... % upvar 0 foo::bar soom can't access "foo::bar": parent namespace doesn't exist That seems counter to the spirit of [upvar] being able to link to non-existent variables. Seems similar to other situations where one would think that namespaces would be created as needed. | ||||
| User Comments: | ||||
msofer added on 2002-07-18 20:44:06:
Logged In: YES user_id=148712 This looks OK to me, it is perfectly consistent with % set foo::bar soom can't set "foo::bar": parent namespace doesn't exist If this is the desired behaviour is an entirely different matter ;) dgp added on 2002-07-18 21:38:25:
Logged In: YES user_id=80530 Fair enough. This is really an FR then. Is there already an FR filed asking that namespaces get created as needed? msofer added on 2002-07-19 02:41:54:
Logged In: YES user_id=148712 I couldn't find any. dgp added on 2002-07-19 03:07:56:
Logged In: YES user_id=80530 more generally then, consider this a request that whenever a "namespace does not exist" error message is currently being returned, instead have the required namespace created automatically, just as variables are created as needed without any prior "declaration". msofer added on 2003-08-10 21:40:57:
Logged In: YES
user_id=148712
Another example reported by Michael Kirkham <muonics> in
[Bug 786187]:
% namespace children ::
::tcl
% proc ns::test {} {}
can't create procedure "ns::test": unknown namespace
% proc test {} {}
% rename test ns::test
% namespace children ::
::ns ::tcl
msofer added on 2003-08-10 21:43:44:
Logged In: YES user_id=148712 The docs do not really talk about the issue. However, this being very longstanding behaviour (since 8.0) I'm hesitant to fix it within a minor release. Maybe it should be TIPped? For the record, my (non-voting) opinion on such a TIP would be YES. dgp added on 2003-08-11 00:06:53:
Logged In: YES user_id=80530 No doubt a TIP is needed; that's why it's a feature request. The only argument against it, I think, is that the error behavior currently implemented makes it easier to discover bugs created by typos in namespace names. jenglish added on 2003-10-07 04:36:31:
Logged In: YES user_id=68433 If $otherVar refers to a nonexistent namespace "foo", should "foo" be created as a subnamespace of the current namespace, or of the root? Either way, it could lead to more subtle problems like the "creative writing" dilemma. dgp added on 2003-10-07 04:37:32:
Logged In: YES user_id=80530 Note that this misfeature contributes to Tk Bug 793909. It is likely there are several similar bugs in Tk, and perhaps in other extensions originally written for Tcl 7 that assume that Tcl_SetVar() will always succeed in creating a variable, and Tcl_TraceVar() will always succeed in creating a variable trace. | ||||
